string p = this.pictureBox1.ImageLocation; string name = this.textBox1.Text; string description = this.richTextBox1.Text; DateTime da = new DateTime(); string date = da.ToString("dd/MM/YYYY"); string connString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Gardezi\Documents\Visual Studio 2012\Projects\homeWork2\homeWork2\Database1.mdf;Integrated Security=True"; SqlConnection con = new SqlConnection(connString); string query = "insert into diaryDB([Title] , [Description] , [Date] , pic) values (@name , @description ,@date , @p)"; SqlCommand comm = new SqlCommand(query, con); comm.Parameters.AddWithValue("@name", name); comm.Parameters.AddWithValue("@description", description); comm.Parameters.AddWithValue("date", da); comm.Parameters.AddWithValue("@p", p); con.Open(); comm.ExecuteNonQuery(); con.Close();
DateTime da = new DateTime();
DateTime da = DateTime.Now;
comm.Parameters.AddWithValue("@date", da);
{1/1/0001 12:00:00 AM}
da
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)