update SQL command in C#

103 views Asked by At

I'm having some troubles parsing SQL query, I'm trying to update the database. I have a database as follows:

name: Users
columns:
ID (int)
userName (string)
LastConnected (string)
isConnected (string)

I tried this:

SqlCeCommand upDateUserAsConnected = new SqlCeCommand("(update Users set isConnected='Connected' where ID=" + userID + " and userName='"+userName+"')", cn);

and that's not working... what did I do wrong?

1

There are 1 answers

0
Rabbiya Shahid On

First of all you don't need parentheses within the query string. Second of all, you have merely written the query here, have you tried to execute it as non-query? How exactly are you running this query?