i have tried to my extent
my coding is:
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\db\report.mdb;")
cn.Open()
Dim ob As New System.IO.StreamReader("..\db\BiopsyExport.csv")
Dim ar(16) As String
Dim i, y As Integer
Dim c, r, ind As Integer
c = 0
r = 0
Dim str, str1 As String
str = ob.ReadToEnd
Do While ob.Peek() >= -1
For i = 1 To 15
ind = str.IndexOf(",", r)
ar(i) = str.Substring(c, ind - c)
c = ind + 1
r = ind + 1
' MsgBox(ar(i).ToString)
'If (ar(i) = ".") Then
'End If
Next i
Loop
Dim command As String
command = "insert into report1(SNo,sysdate,RefNo,Name,FHName,Address,Age,Sex,SpecimenDate,ReportDate,Histopathology,Impression,OtherNotes,ExportedOn)" & " values(" & ar(1) & ",'" & ar(2) & "'," & ar(3) & ",'" & ar(4) & "','" & ar(5) & "','" & ar(6) & "'," & ar(7) & ",'" & ar(8) & "','" & ar(9) & "','" & ar(10) & "','" & ar(11) & "','" & ar(12) & "','" & ar(13) & "','" & ar(14) & "')"
'command = "insert into report1(SNo,sysdate,RefNo,Name,FHName,Address,Age,Sex,SpecimenDate,ReportDate,Histopathology,Impression,OtherNotes,ExportedOn)" & " values('" & ar(i) & "')"
cmd = New OleDbCommand(command, cn)
cmd.ExecuteNonQuery()
MsgBox("inserted successfully")
Catch ex As Exception
MessageBox.Show(ex.Message & " - " & ex.Source)
End Try
but it gives me an error as
Length cannot be less than zero
parameter name:length-mscorlib
do help me
i want to insert all the datas inside the csv file into another table by name report1
Enter your message below
Sign in or Join us (it's free).