DataTable dt = new DataTable();
dt.Columns.Add("L_DateTime");
dt.Columns.Add("L_Direction");
dt.Columns.Add("L_CardID");
dt.Columns.Add("L_GateID");
int i2 = 0;
while ((inputLine = rdr.ReadLine()) != null)
{
string[] arr;
arr = inputLine.Split(',');
row = dt.NewRow();
row["L_DateTime"] = Convert.ToDateTime(arr[0]);
row["L_Direction"] = arr[1];
row["L_CardID"] = arr[2];
row["L_GateID"] = Convert.ToInt32(arr[3]);
dt.Rows.Add(row);
i2++;
}
sqlbulkCopy.WriteToServer(dt);
sqlbulkCopy.Close();
Greeting everyone...i have problem here...
let me explain a little bit what this code is all about...
im using sqlbulk to read data from text file, and store it in database. As far as im aware in text file, the data all treated as string(perhaps)!..
earlier in my database i have created rows which name are exactly as in this code..
first in my sql dbase, im treated all data as string..and it is working fine..
but since it involving datetime...i change it to suitable type...
and i strting to get error...said :STRING WAS NOT RECOGNIZED AS A VALID DATETIME!!!
i dont understand...i have already converted it to datetime...any suggestion would be nice....regards to all coders!!