convert c# data to sql data

C

Chi Tang

Hi,

Does anybody know where I can get some samples to pass C# data to sql data?
For example, I need to pass some date data to a sql 'smalldatatime' data but
I did not know how. Thanks,

CT
 
K

Kathleen Dollard

Chi,

Can you post the code that isn't working for you?

There are samples in the quick starts

Kathleen
 
C

Chi Tang

Hi,

The following code shows that I try to pass a 'smalldatetime' data to the
'Today_Date' column when I add a new row to a table. I use the
'DateTimeFormatInfo' object to get the today date but did not know how to
convert to a sql 'smalldatetime'. Thanks for help.

DataSet ds = new DataSet("MyTable");

adapter.Fill(ds, "MyTable");

DataTable tbl = ds.Tables["MyTable];


DataRow row = tbl.NewRow();

row["Today_Date"] = ?; // this column data is a smalldatetime in sql

tbl.Rows.Add(row);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top