Ecco il mio codice:
string data = dateTimePicker1.Value.ToString("dd/MM/yyyy HH:mm:ss");
DateTime datePub = new DateTime();
datePub = Convert.ToDateTime(data);
textBox1.Text = datePub.ToString();
SqlConnection scn = new SqlConnection(@"Data Source=WS065\SQLEXPRESS;Initial Catalog=Pub;User ID=sa;password=inmatica");
SqlCommand scm = new SqlCommand("INSERT into titles (title_id,title,type,pub_id,price,advance,royalty, ytd_sales,notes,pubdate) values ('"
+ title_Id + "','" + title + "','" + type + "','" + pub_Id + "','" + price + "','" + advance + "'," + royalty + ","
+ ytd_Sales + ",'" + notes + "','" + datePub + "')", scn);
scn.Open();
scm.ExecuteNonQuery();
scn.Close();

Rispondi quotando