-1

I am trying to save some data to access DB but the date is stored in incorrect format

dbCommand.CommandText = "insert into Clients(Name,Gender,PhoneNumber,ReciveServiceDate) 
values ('" + name_txtBox.Text + "','" + gender_comBox.Text + "'," 
+ long.Parse(phone_txtBox.Text) + "," 
+ (recive_dateTimePicker.Value).ToShortDateString() + ");";

this is how date looks like in DB

MethodMan
  • 18,625
  • 6
  • 34
  • 52
  • 5
    First thing to do: stop putting values directly into your SQL. Use parameterized SQL instead. That may very well fix your issue... – Jon Skeet Feb 26 '15 at 19:02
  • [C# Using Parameters inserting into Access DB](http://stackoverflow.com/questions/5893837/using-parameters-inserting-data-into-access-database) – MethodMan Feb 26 '15 at 19:06

1 Answers1

0

Listen to Jon's advice.

However, if you insist, you can do it like this:

+ (recive_dateTimePicker.Value).ToString("#yyyy'/'MM'/'dd#") + ");";
Gustav
  • 53,498
  • 7
  • 29
  • 55