Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am having no luck doing this. The field in the database is set to Date/Time with the format being Short Date.

 

In the C# code i have a DateTime object which i read the date into as a ShortDateString so it only stores the date in the format of 5/27/04.

 

when i go to insert into this field using a query string like this:

query = "INSERT INTO tblStorage (dateOfEntry, GsharesOwned) " +

"Values ('#" + date +"#', '" +GsharesOwned +"')";

 

 

the following error is caught: "data type mismatch in criteria expression".

 

i read somewhere to include a # before and after the date, well it does not work whether these are included or not. the only way i can insert a date is to change the field type to text, then this query string allows me to insert into the date field.

 

my reason for needing the field to be declared a date/time field is so i can sort it based on the date vs having to write my own function to sort if the dates were just strings.

 

how can i insert into a Date/Time field? i am using C# and Access as the database for a windows app. thanks.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...