Ajith s

Ajith s

  • NA
  • 9
  • 8.2k

regarding updating the table in Asp.net

Dec 5 2012 11:12 PM
Hi
I have created a simple application using two text boxes,one is for the username and other is for the password.And i have a button to submit
I have created the table with two columns (i.e)users,pass   in sql server
In my application when i enter details in the text boxes i get an error at the run time in the browser (ie)'xxx' is not a column name....

here is the code below
protected void upd_Click(object sender, EventArgs e)
    {
        SqlConnection cn = new SqlConnection(@"Put the Connection String");
        cn.Open();
        SqlCommand cmd = new SqlCommand("UPDATE aa SET pass ='" +TextBox2.Text.Trim() + "', WHERE users=" + TextBox1.Text.Trim() + "", cn);
        cmd.ExecuteNonQuery();
        cn.Close();
        load();
    }

I was not able to update the fields in the table,when i give the username and password......
but when i give the column name as the username in the textbox1 the password gets updated in the entire column  

Answers (3)