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!!!");

Sachin SinghRank #66 · 26.2K reputationPosted Jan 28, 2021, 11:13 AM EST
Sachin SinghRank #66 · 26.2K reputationPosted Feb 6, 2021, 11:25 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Feb 6, 2021, 11:13 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Feb 6, 2021, 11:30 AM EST
Eduard Szigeti8 reputationPosted Jan 28, 2021, 2:58 PM EST
Jose HernandezRank #2,683 · 519 reputationPosted Feb 5, 2021, 11:35 PM EST
Jignesh KumarRank #91 · 22.9K reputationPosted Feb 9, 2021, 2:20 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Feb 9, 2021, 8:23 AM EST