Click here to Skip to main content
15,889,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

C#
string str1 = "update Login_Table set p_word=" + TextBox2.Text + " where user_name='" + Session["name"].ToString() + "'";

cmd = new SqlCommand();
cmd.CommandText = str1;
cmd.Connection = db.con;
cmd.ExecuteNonQuery();


I am getting error like , invalid column name. I am bad at writing queries.
Posted
Comments
Surendra Adhikari SA 16-Jun-13 2:03am    
error is self explaining.. i.e. you have to check for column name in Login_Table. You must match column name in your commandtext . can you give your table structure then we can update your quiry string.
Parth Dotnet1 16-Jun-13 2:08am    
sure its user_name , p_word , flag

i am taking user_name value from seesion

flag is for activation of account from admin side
Surendra Adhikari SA 16-Jun-13 4:36am    
its fine then.

1 solution

is your password column column is numeric??
probably not. so it should be p_word='" + TextBox2.Text + "' .you have to give password in quoate as it is a string .copy and enjoy :
C#
string str1 = "update Login_Table set p_word='" + TextBox2.Text + "' where user_name='" + Session["name"].ToString() + "'";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900