0

I need to update the details in a certain row of my SQL Server CE database as the user wants requires to. But I get an error

There was an error parsing the query.[Token line number=1,Token line offset=31,Token in error=Name]

My query is:

"Update MembersTable set First Name='" + txtFirstName.Text +
    "', Surname='" + txtSurname.Text + 
    "', Middle Name='" + txtMiddleName.Text +
    "',Home Address='" + txtAddress.Text +
    "',Date Of Birth='" + dtpDOB.Text + 
    "',Home Phone No='" + txtHomePhone.Text +
    "',Mobile No='" + txtMobilePhone.Text + 
    "',Email='" + txtEmail.Text +
    "',Profession='" + txtProfession.Text + 
    "',Cell Leaders Name='" + txtCellLeader.Text +
    "' Where ID='" + DC.ID + "'";"

What am I doing wrong??

1
  • SQL Injection alert - you should not concatenate together your SQL statements - use parametrized queries instead to avoid SQL injection Commented Mar 2, 2015 at 11:35

1 Answer 1

1

It appears like your column names contain spaces. To deal with this, you'd want to enclose the column name with square brackets [ ]

"Update MembersTable set [First Name]='" + txtFirstName.Text + "',Surname='" + txtSurname.Text + "',[Middle Name]='" // ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.