I have this code, but it only inserts 7 records out of 54.
I am sure that the records are fine in the datatable.
Dim dt As DataTable
Dim sc As SQLiteCommand
Dim Script As String = Nothing
Dim Script2 As String = Nothing
Dim Script3 As String = Nothing
Script = "insert into paperdate(dtime,papernum,paperstat,user) select " & "'" & dt.Rows(0)(0) & "'" & " as " & "dtime" & "," & dt.Rows(0)(1) & " as " & "papernum" & "," & "'" & dt.Rows(0)(2) & "'" & " as " & "paperstat" & "," & "'" & dt.Rows(0)(3) & "'" & " as " & "user"
For i As Integer = 1 To dt.Rows.Count - 1
Script2 = " union select " & "'" & dt.Rows(i)(0) & "'" & "," & dt.Rows(i)(1) & "," & "'" & dt.Rows(i)(2) & "'" & "," & "'" & dt.Rows(i)(3) & "'"
Script3 = Script3 & Script2
Next
sc = New SQLiteCommand(Script & Script3, mycon)
sc.ExecuteNonQuery()
sc.Dispose()
I hope someone has the answer,
thanks
It may be that you have duplicate records in the second select. If that is the case, then the solution is to use
UNION ALLinstead ofUNION.Reference: http://www.sqlite.org/lang_select.html
If that isn’t it, then you might want to trace the SQL, and run the
SELECTparts directly in the sqlite client.Update
As per your comment, here is the change you would do to your code:
becomes