I am trying to insert new records into an Access DB and getting some weird stuff.
I get the data from a DBF table and load that into a dataset table and DataGridView with no problems.
Then I loop through the ds.table and insert it into the DB with this query.
cmd.CommandText = "INSERT INTO GRINDITEMS (MODE, PERIOD, lngHOUR, lngMINUTE, DOB, SYSDATE)" & _
" VALUES (" & _
ds.Tables(0).Rows(iRows).Item(1) & "," & _
ds.Tables(0).Rows(iRows).Item(2) & "," & _
ds.Tables(0).Rows(iRows).Item(3) & "," & _
ds.Tables(0).Rows(iRows).Item(4) & "," & _
ds.Tables(0).Rows(iRows).Item(5) & "," & _
ds.Tables(0).Rows(iRows).Item(6) & ")"
cmd.ExecuteNonQuery()
All the columns are fine except the date columns (DOB and SYSDATE); they take a date like '8/01/2012' from the DBF and it reads in the DataSet Table as '8/01/2012' (as evidenced in a DataGridView) but it ends up being written to the Access table as '12-30-1899'. Note those columns in the DB are set as Date/Time with ShortDate format.
If I change the DB column DataType to 'text' is write as '3.97614314115308E-03'!!!
I've tried a bunch of formatting tricks and that hasn't worked either. Need some help here and hoping someone can tell me where/when (best practice) I should make any Format changes; in the first read from the DBF or when a INSERT to Access DB.
Thanks in advance,