0

这是正常的吗?当我将数据从 14k 记录导出到 XML 时,我无法单击表单中的任何内容?而且我认为我的表格冻结了。我正在使用 vb.net 从数据库中导出文件。希望听到积极的回应。

代码 :

    Using xmlWriter As XmlWriter = xmlWriter.Create(oFileName, xmlSetting)

                    xmlWriter.WriteStartDocument()
                    xmlWriter.WriteStartElement("Products")
                    xmlWriter.WriteAttributeString("type", "array")

                    oDotNet.SqlDb.strCommand = "SELECT IsNULL(SuppCatNum, '') [Stock No], " & _
                                                " ItemCode, " & _
                                                " IsNULL(CodeBars, '') [BardCode List], " & _
                                                " IsNULL(FrgnName, '') [FrgnName], " & _
                                                " ItemName, " & _
                                                " IsNULL(InvntryUom, '') [InvntryUom], " & _
                                                " b.ItmsGrpCod [Category Code], " & _
                                                " b.ItmsGrpNam [Category Name], " & _
                                                " a.QryGroup1 [Allow Decimal], " & _
                                                " Vat.Rate, " & _
                                                " a.ManSerNum, " & _
                                                " IsNULL(a.CardCode, '-1') [CardCode]" & _
                                                " FROM OITM a" & _
                                                " INNER JOIN OITB b ON a.ItmsGrpCod = b.ItmsGrpCod " & _
                                                " INNER JOIN OVTG Vat ON a.VatGourpSa = Vat.Code " '& _
'" WHERE ItemCode = 'Davies EL-0020 White'"
                    ts_Progress.Maximum = oDotNet.SqlDb.Ds.Tables(0).DefaultView.Count

                    For i As Integer = 0 To oDotNet.SqlDb.Ds.Tables(0).DefaultView.Count - 1

                        xmlWriter.WriteStartElement("Product")
                        xmlWriter.WriteElementString("id", -1)
                        xmlWriter.WriteElementString("stock_no", oDotNet.SqlDb.GetField(i, "Stock No"))
                        xmlWriter.WriteElementString("reference", oDotNet.SqlDb.GetField(i, "ItemCode"))

                        xmlWriter.WriteElementString("name", oDotNet.SqlDb.GetField(i, "ItemName"))
                        xmlWriter.WriteElementString("short_name", oDotNet.SqlDb.GetField(i, "FrgnName"))
                        xmlWriter.WriteElementString("supplier_code", oDotNet.SqlDb.GetField(i, "CardCode"))

'*BardCode*'
                        Select Case oType
                            Case 1
Dim _BardCode As String = Nothing
                                oSql.strCommand = "SELECT BcdCode FROM OBCD bcd INNER JOIN OUOM uom ON bcd.UomEntry = uom.UomEntry " & _
                                                    " WHERE ItemCode = '" & oDotNet.SqlDb.GetField(i, "ItemCode") & "' AND bcd.BcdCode != '" & oDotNet.SqlDb.GetField(i, "BardCode List") & "' " & _
                                                    " /*AND uom.UomCode = '" & oDotNet.SqlDb.GetField(i, "InvntryUom") & "'*/ "
                                If oSql.Ds.Tables(0).DefaultView.Count > 0 Then
                                    For oBardCode As Integer = 0 To oSql.Ds.Tables(0).DefaultView.Count - 1
                                        _BardCode &= oSql.GetField(oBardCode).ToString & ", "
                                    Next
                                    _BardCode = oDotNet.SqlDb.GetField(i, "BardCode List") & ", " & _BardCode.Substring(0, _BardCode.Length - 2)

                                Else
                                    _BardCode = oDotNet.SqlDb.GetField(i, "BardCode List")

                                End If


                                xmlWriter.WriteElementString("barcode_list", _BardCode)
                                xmlWriter.WriteElementString("category_id", -1) 
                                xmlWriter.WriteElementString("unit_name", oDotNet.SqlDb.GetField(i, "InvntryUom")) 'oDotNet.SqlDb.GetField(i, "InvntryUom"))
                                xmlWriter.WriteElementString("retail_price", "")

'*WhsCode Here*'
Dim _WhsCode As String = Nothing
                                oSql.strCommand = "SELECT WhsCode FROM OITW WHERE ItemCode = '" & oDotNet.SqlDb.GetField(i, "ItemCode") & "' "
                                For oWhsCode As Integer = 0 To oSql.Ds.Tables(0).DefaultView.Count - 1
                                    _WhsCode &= oSql.GetField(oWhsCode).ToString & ", "
                                Next

                                _WhsCode = _WhsCode.Substring(0, _WhsCode.Length - 2)

                        End Select


                        xmlWriter.WriteEndElement()
                        ts_Value += 1

                        ts_Progress.Value = ts_Value 
                    Next

                    xmlWriter.WriteEndElement()
                    xmlWriter.WriteEndDocument()

                End Using
4

1 回答 1

1

你可以试试Application.DoEvents这是一个非常草率但很容易解决你的问题的方法。它将允许您仍然使用表单,但它会很慢。

于 2013-07-29T16:50:05.567 回答