3
Reply

regarding updating the table in Asp.net

Ask a question
Ajith s

Ajith s

11y
2.4k
1
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)