选项卡分隔的文件vb.net访问97
我必须从非规范化表导入产品才能访问97文件。此方案无法更改,因此我无法使用SQL。我使用以下例程导入产品。文件中有7000多个产品,此功能需要很长时间。有没有办法加快速度选项卡分隔的文件vb.net访问97,vb.net,ms-access,Vb.net,Ms Access,我必须从非规范化表导入产品才能访问97文件。此方案无法更改,因此我无法使用SQL。我使用以下例程导入产品。文件中有7000多个产品,此功能需要很长时间。有没有办法加快速度 Public Sub ImportToOrders() Try 'Dim actualFileName As String = IO.Path.GetFileName(filename) 'Dim streamReader As New IO.StreamReader(filename
Public Sub ImportToOrders()
Try
'Dim actualFileName As String = IO.Path.GetFileName(filename)
'Dim streamReader As New IO.StreamReader(filename)
'Dim streamWriter As New IO.StreamWriter(filename & ".tsv")
'streamWriter.WriteLine()
'streamWriter.Close()
'streamWriter.Dispose()
Dim strFile As String = "C:\windows\figure.ini"
Dim strRet As String
Dim inifile As New IniFileManager
strRet = inifile.ReadINI(strFile, "DATABASE SECTION", "FILENAME", "")
Dim strPriCatFile As String = ""
strPriCatFile = "C:\three_software\incoming\skechers\Pricat.edi.tsv"
Dim fields As String()
Dim counter As Integer = 0
Dim delimiter As String = ControlChars.Tab
Using parser As New TextFieldParser(strPriCatFile)
parser.SetDelimiters(delimiter)
While Not parser.EndOfData
counter = counter + 1
' Read in the fields for the current line
fields = parser.ReadFields()
If counter = 1 Then
'this will be the header row we want to ignore this
Else
' the fiels we will go ahead and parse
WriteData(fields(1), fields(3), fields(4), fields(6), fields(5), fields(11), fields(8), fields(9), fields(11), fields(10), fields(12), fields(13), fields(14), "t")
End If
Debug.Write("Records Importing" + counter.ToString())
End While
End Using
Catch ex As Exception
MsgBox(ex.ToString())
End Try
写数据函数
Public Function WriteData(sUPCode As String, sColourDescription As String, sSize As String, sColorCode As String, sDivsionDescription As String, sDescription As String, sDepartment As String, sSubDeparment As String, sProductShortDescription As String, sGender As String, sProductDescription As String, sCostPrice As String, sRetailPrice As String, sDiscountedPrice As String)
Try
Dim pricateTableAdapter As New SkechersPricatTableAdapter()
pricateTableAdapter.Insert(1, sUPCode, "stylenumber", sColourDescription, sSize, sColorCode, sDivsionDescription, sDepartment, sSubDeparment, sProductShortDescription, sGender, sProductDescription, sCostPrice, sRetailPrice, sDiscountedPrice)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Function
首先,您有一些变量没有使用,If counter=1 Else语句可以固定为If counter>1,然后。。。因为它是您的标题行。请尝试将Dim pricateTableAdapter在作用域中上移一个级别,即模块级别。寻找加载源表的其他选项,例如。