I wanted to update the cell of the table, but when I did that by writing this code, the table does not get updated and there was no any exceptions or any errors:
protected void btn_Click(object sender, EventArgs e)
{
using(SqlConnection con = new SqlConnection("My connection string"))
{
SqlCommand command = new SqlCommand("UPDATE [Tablename] SET [notes]=@notes WHERE [ID]=@ID", con);
command.Parameters.AddWithValue("@ID", this.ID);
command.Parameters.AddWithValue("@notes", TextBox1.Text);
con.Open();
command.ExecuteNonQuery();
con.Close();
}
}
When I pass the value of "@notes" by myself it works, but when pass the value of "@notes" TextBox1.Text it is not working. Can someone explain me why?
Note: TextBox1.TextMode is Multiline
TextBox1.Textexactly? And usingcon.Close()is redundant.usingstatement will handle that.