So I have code that stores an UPDATE query in a string, then I parameter bind the update query and then execute and update it, this is my code:

string query = "UPDATE Users SET first_name = '@firstname' WHERE ID = @id";
updateUserDS.UpdateParameters.Add("id", HTTPContext.Current.Session["ColumnID"].ToString());
updateUserDS.UpdateParameters.Add("firstname", txt_firstname.Text);
updateUserDS.UpdateCommand = query; 
updateUserDS.Update();

However when I change my string query to:

string query = "UPDATE Users SET first_name = 'name' WHERE ID = 44";

It works perfectly and updates my table, so I am guessing its something to do with how I have binded the query, does anyone realise anything where I have gone wrong?

BTW: The Session["ColumnID"] is being retrieved perfectly as it states 44 in the stack trace

Related posts

Recent Viewed