Click here to Skip to main content
15,904,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I'm attempting to push data into my local access database. All data being pushed is of the string data type.

Here is my code:
C#
com.Parameters.Add("@date", OleDbType.VarWChar).Value = date;                    
com.Parameters.Add("@system", OleDbType.VarWChar).Value = system;                    
com.Parameters.Add("@start", OleDbType.VarWChar).Value = start;                    
com.Parameters.Add("@end", OleDbType.VarWChar).Value = end;                    
com.Parameters.Add("@station", OleDbType.VarWChar).Value = station;                    
com.Parameters.Add("@coordse", OleDbType.VarWChar).Value = coordse;                    
com.Parameters.Add("@coordsn", OleDbType.VarWChar).Value = coordsn;

The columns in my database are of both Text and Date/Time format.
@date, @start, and @end are of the Date/Time format and the rest are of the Text data type.

I've tried some variations in the OleDbType but I can't seem to get the right combination.

Any ideas?
Posted
Updated 29-Sep-10 3:59am
v2

com.Parameters.Add("@date", OleDbType.VarWChar).Value = date; 


You're setting the var type as a varchar. It should be a date type.
 
Share this answer
 
use OleDbType.VarChar instead of OleDbType.VarWChar for text,

and use OleDbType.Date for the Date format data.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
Comments
GianniOD 29-Sep-10 10:54am    
I tried both of these before but just to make sure I tried again. Still receiving the same error. Any other ideas of what could be causing this error?
SOLVED

Some parameters that defined the format of the data in my database differed from the format of my strings in my program. Once I got them all matched up everything worked fine.

Thanks!
 
Share this answer
 
Comments
Hiren solanki 30-Sep-10 1:38am    
cool.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900