first record is missing

ahbenshaut

Well-known member
Joined
Oct 29, 2004
Messages
62
Location
Alaska
Programming Experience
5-10
I am trying to import a csv file to a data table. The function works fine except the first record is missing. I am using a schema.ini file with the following:
VB.NET:
[UWCLoans.csv]
Format = CSVDelimited
Col1 = GUID text
Col2 = LoanNumber text
Any ideas would be greatly appreciated.
VB.NET:
    Private Sub ImportData(strFileName As String)
        ProgressBar1.Minimum = 1
        ProgressBar1.Value = 1
        ProgressBar1.Step = 1
        Dim FilePath As String = strFileName
        Dim FileName As String = Path.GetFileName(strFileName)
        Dim FileFolder As String = Path.GetDirectoryName(strFileName)
        'MessageBox.Show(FileName & vbCrLf & FileFolder)
        Dim CnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileFolder & ";Extended Properties=""text;HDR=NO;FMT=Delimited'"";"
        Using Adp As New OleDbDataAdapter("select * from " & FileName, CnStr)
            Adp.Fill(dt)
            ProgressBar1.Maximum = dt.Rows.Count
            If dt.Rows.Count > 0 Then
                For i = 0 To dt.Rows.Count - 1
                    txtMessages.AppendText("Imported: " & dt.Rows(i).Item(1) & vbCrLf)
                    ProgressBar1.PerformStep()
                Next
                txtMessages.AppendText("Records imported: " & dt.Rows.Count.ToString)
                ProgressBar1.Value = 1
            End If
        End Using
    End Sub
 
Top Bottom