Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anybody would like to help. It gives error of "Incorrect syntax near ','."


SQL
Dim cmd As New SqlCommand
      cmd.CommandText = "UPDATE tblPersonnel SET @Date,@FirstName,@LastName,@CaseNumber,@CaseResult,@PhotoName WHERE ImageID='" + Trim(comID.Text) + "')"
      cmd.CommandType = CommandType.Text
      cmd.Connection = conn
      cmd.Parameters.Add("@Date", SqlDbType.Date).Value = Format(DateInput.Value, "M/dd/yyyy")
      cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = comFirstName.Text
      cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value = comLastName.Text
      cmd.Parameters.Add("@CaseNumber", SqlDbType.VarChar).Value = comboCaseNumber.Text
      cmd.Parameters.Add("@CaseResult", SqlDbType.VarChar).Value = comboResult.Text
      cmd.Parameters.Add("@PhotoName", SqlDbType.VarChar).Value = textboxImageName.Text
      cmd.ExecuteNonQuery()
Posted

I am not sure but I guess this is sql stamen should be SET Date=@Date instead of SET @Date. Assuming Date is the table field. Same should be for all other fields.
 
Share this answer
 
you need to specify column name to put these values like Date = @date, in your query
 
Share this answer
 
I m also not sure, but I think that your ImageID is type of int.
And you're using it as a string in your query.

So make following kind of changes,
"UPDATE tblPersonnel SET @Date,@FirstName,@LastName,@CaseNumber,@CaseResult,@PhotoName WHERE ImageID= '" + Trim(comID.Text) + "')"
or
ImageID = int.Parse(Trim(comID.Text));

-KR
 
Share this answer
 
Run your query on the database directly to ensure it is working.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900