制表符分隔文件vb.net到Access 97

时间:2014-03-20 12:46:22

标签: vb.net ms-access

我必须将非规范化表中的产品导入Access 97文件。这个方案不能改变,所以我不能使用SQL。我使用以下例程导入产品。文件中有7000多种产品,功能需要很长时间。有没有办法加快速度?

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

0 个答案:

没有答案