想写一个函数,将传递进来的两值通过查询数据库后填到对应的位置,但老是提示出错,我新手学习,希望能得到大家的帮助。代码如下。
Private Function addzkg(ByVal groups As Integer, ByVal Examiner As String)
Dim sqlcmd As SqlCommand
Dim recordnum As Integer
Dim sqltext As String = "update aa02 set Examiner_1=" + Examiner + " where groups=" + groups + ""
'Dim sqltext As String = "update aa02 set Examiner_1='张三' where groups=1"
sqlcmd = New SqlCommand(sqltext, conn)
conn.Open()
sqlcmd.ExecuteNonQuery()
conn.Close()
Return recordnum
End Function
------解决方案--------------------
字符串差单引号
Dim sqltext As String = "update aa02 set Examiner_1= '" + Examiner + "' where groups=" + groups + ""
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/