I have a system where i capture Student Session Information in SQL Server table. In SessionDetail table i have SID,StartTime,EndTme,SessiondDate,TherapistID(TID).
Now we get a Excel file from provider with billing information and we have to add StartTime,EndTime for the kids based on SID and TID match. We automate this process and add starttime and endtime throught our system and update the excel sheet rather doing it manually.
Now i have this code in place.
string selectString = "Update [Sheet1$] set StartTime = '10:30',EndTime='11:00' where SID='12'";
con = new OleDbConnection(connectionString);
cmd = new OleDbCommand(selectString, con);
con.Open();
cmd.ExecuteNonQuery();
and this works fine when i put SID or/and TID in where condition and update the sheet. But when i add the sessiondate in where condition it dosent update anything. i tried by adding just SessionDate in where condition it dosent update anything. SID and TID are formatted as Number in Excel sheet and date is formatted as [$-1010409 mm/dd/yyyy] in excel sheet.
I thought its something with date and string comparison on date filed and datatypes are not matching. SO i tried this query
string selectString = "Update [Sheet1$] set SCIN_ACT_GRP_SIZE = 'P' where sessiondate=09/09/2014";
and
string selectString = "Update [Sheet1$] set SCIN_ACT_GRP_SIZE = 'P' where SessionDate='09/09/2014'";
one with '' and on without '' around date in where clause. First one execute but dost update the sheet and another one gives critical datatype mismatch error when its executed.
i am lost and not sure what to do.Please help.
Thanks.