Eduard Szigeti

Eduard Szigeti

  • NA
  • 6
  • 632

Table not updating

Jan 28 2021 3:23 PM
I have this code that I try to fill a table in a databse.
I push the ok button, I receive no error but nothing is in my table.
can anyone tell me what could be wrong?
Thanks 
 
 
private void button1_Click(object sender, EventArgs e)
{
string conection = @" Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Edy\Visual Studio\Last planner system\Last planner system\planning data.mdf";
using (SqlConnection con = new SqlConnection(conection))
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO (Project name) values (Name, Starting date, End date, Description ");
cmd.Parameters.Add("Name", SqlDbType.NVarChar).Value = txtName.Text;
cmd.Parameters.Add("Starting date ", SqlDbType.Date).Value = txtStartDate.Text;
cmd.Parameters.Add("End date", SqlDbType.Date).Value = TxtEndDate.Text;
cmd.Parameters.Add("Description", SqlDbType.Text).Value = txtDescription.Text;
using (SqlConnection con1 = new SqlConnection(conection))
con1.Close();
MessageBox.Show("Done!!!");

Answers (8)