','附近的语法不正确。 [英] Incorrect syntax near ','.

查看:71
本文介绍了','附近的语法不正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人愿意提供帮助。它给出了语法不正确','错误。





 Dim cmd  As 新的SqlCommand 
cmd.CommandText = UPDATE tblPersonnel SET @ Date,@ FirstName,@ LastName,@ CaseNumber,@ CaseResult,@ PhotoName WHERE ImageID =' + Trim(comID。 Text )+ ')
cmd.CommandType = CommandType。文字
cmd.Connection = conn
cmd.Parameters。添加 @ Date,SqlDbType。 Date )。Value = Format(DateInput.Value, M / dd / yyyy
cmd.Parameters。添加 @ FirstName,SqlDbType。 VarChar )。Value = comFirstName。文字
cmd.Parameters。添加 @ LastName,SqlDbType。 VarChar )。Value = comLastName。 Text
cmd.Parameters。添加 @ CaseNumber,SqlDbType。 VarChar )。Value = comboCaseNumber。 Text
cmd .Parameters。添加 @ CaseResult,SqlDbType。 VarChar )。Value = comboResult。 Text
cmd.Parameters。添加(<跨度class =code-string> @ PhotoName,SqlDbType。 VarChar )。 Value = textboxImageName。 Text
cmd.ExecuteNonQuery()

解决方案

< blockquote>我不确定,但我猜这是sql stamen应该是SET Date = @ Date而不是SET @Date。假设Date是表字段。对于所有其他字段应该相同。


您需要在查询中指定列名以将这些值设置为Date = @date


I我也不确定,但我认为你的ImageID是 int 的类型。

并且你将它用作字符串。



因此,请进行以下类型的更改,

UPDATE tblPersonnel SET @ Date,@ FirstName,@ LastName,@ CaseNumber,@ CaseResult,@ PhotoName WHERE ImageID ='+ Trim(comID.Text)+')



ImageID = int.Parse(Trim(comID.Text));



-KR


Anybody would like to help. It gives error of "Incorrect syntax near ','."


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()

解决方案

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.


you need to specify column name to put these values like Date = @date, in your query


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


这篇关于','附近的语法不正确。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆