Error Calling Update Query

  • Thread starter Thread starter Joe Keller
  • Start date Start date
J

Joe Keller

Hello,

I'm getting an "error parsing query" when I attempt to run this portion of
code to update my DB (see code below). Any suggestions as to what I could
be doing wrong?

string sSQL = "UPDATE tblInventoryItem SET sItemName = @sItemName where
lInventoryItemID = @lInventoryItemID";
da2.UpdateCommand = new SqlCeCommand(sSQL, myConn);
da2.UpdateCommand.Parameters.Add("@sItemName", SqlDbType.NVarChar, 30);
da2.UpdateCommand.Parameters.Add("@lInventoryItemID", SqlDbType.Int);
da2.Update(dt2);

If I use the Command Builder to generate the SQL, everything works fine (see
code below).
cbrJobs = new SqlCeCommandBuilder(da2);
da2.Update(dt2);

Thanks!

Joe
 
Use ? as parameter placeholders in your CommandText.
@ParamName syntax is only supported in SqlClient, but not in SqlCeClient
 
Back
Top