tags:

views:

35

answers:

2

how to Insert Datetimepicker text in SQL Database as datetime datatype

A: 

Parse the text in C#, and insert the parsed DateTime. Example:

var date = new DateTime(dateTimePickerText);
InsertIntoSqlDatabase(date); // Code for inserting here.
Tomas Lycken
+2  A: 

In order to parse the datetime from datetime picker you can do the following:

string dt = dateTimePicker.Value.ToString("yyyy-mm-dd hh:MM:ss");

And then in order to insert it in your database you can do:

Insert into table (id, mytime) 
values("5",  CONVERT(datetime, CONVERT( varchar(11), dt, 101))

If you need information on how to access your database you can read the following article in CodeProject

ppolyzos
thanks for your answer
KARTHIK V