Dave Howson
Dave Howson

Reputation: 306

Error parsing query from C# program to SQL Server CE

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??

Upvotes: 0

Views: 171

Answers (1)

cbr
cbr

Reputation: 13652

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]='" // ...

Upvotes: 1

Related Questions