0
cmd.CommandText = "update  dbo.diagnosis SET id=" + SetValueForText + "ss=" + sh;

where sh and column ss are of bool datatype and id and SetValueForText are of int datatype. exception is invalid syntax near ss.

1
  • 1
    USE parametrized queries! to avoid SQL injection attacks and improve performance. ... Commented Mar 28, 2013 at 14:15

1 Answer 1

2

You're missing a comma between the first value and the second column name. You should also be using a parameterized query to protect against SQL Injection Attacks:

cmd.CommantText =
    "update dbo.diagnosis set id=@id, ss=@ss";

cmd.Parameters.Add("@id", SetValueForText);
cmd.Parameters.Add("@ss", sh);

Also keep in mind that you're not filtering any values so this update statement will update every row in the table.

Sign up to request clarification or add additional context in comments.

1 Comment

Justin please tell mee wherei have to put comma?

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.