Insert Data into SQL DataBase
Dear all,
I try to insert data into my Database but when I click the button nothing happen I tried to use select statement instead of insert statement and it works well, but when I try ti update or insert data nothing happens, could anybody help me with that?
This is the code:
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\nobel.mdf;Integrated Security=True;User Instance=True";
con.Open();
cmd.CommandText = "INSERT INTO test VALUES (@amount, @description)";
cmd.Parameters.AddWithValue("@amount", Convert.ToInt64(txt_amount.Text));
cmd.Parameters.AddWithValue("@description", rtxt_description.Text);
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();