asp.net c# updating table row
Posted on 2011-10-31
I have an application where I'm creating an online test.
I have a page with several panels. in one panel, users register, after registration, a second panel opens up, users take the test and a label displays the score.
When user clicks "finish", I wrote a function to update a table row.
My codebehind follows:
public void updatetester()
// prepare command string
updateString = "Update Testers (";
updateString += "FirstName, Score)";
updateString += "VALUES (";
updateString += "@FirstName,@Score)";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(updateString, con);
//cmd.Parameters["@Score"].Value = lblScore.Text;
// 1. Instantiate a new command with command text only
// 2. Set the Connection property
cmd.Connection = con;
// 3. Call ExecuteNonQuery to send command
catch (Exception err)
lblUpdateScore.Text = "Error Updating Score. ";
lblUpdateScore.Text += err.Message;
// Close the connection
Panel1.Visible = true;
I am getting the following error message:
Incorrect syntax near '('.
I'm at a loss to fix t h i s
What I would ultimately like to have is a way to select the table row that contains the tester's first name (as captured in the textbox named "txt_FirstName" and update the table field called "Score" (datatype: int)
ANY help with this would be greatly appreciated...