简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM