日期:2014-05-18  浏览次数:20511 次

语法错误问题。。。。帮忙看看
Dim   conn   As   New   SqlConnection
                conn.ConnectionString   =   "data   source=localhost;initial   catalog=HolidaysTest;user   id=aa;password=aa; "
                Dim   sqlupdate   As   String
                sqlupdate   =   "update   voteDetails   set   voteNum=voteNum+1   where   voteid= "   &   voteid   &   "and   votedetailID= "   &   rbtnItems.SelectedValue.tostring   &   " "
                conn.Open()
                Dim   cmd   As   New   SqlCommand(sqlupdate,   conn)
                cmd.ExecuteNonQuery()
                conn.Close()
             
当运行到   cmd.ExecuteNonQuery()出错,说是sql语句中的等号附近有错误。我找不出错在哪里。帮忙看看。。在线等。。。


------解决方案--------------------
Dim conn As New SqlConnection
conn.ConnectionString = "data source=localhost;initial catalog=HolidaysTest;user id=aa;password=aa; "
Dim sqlupdate As String
sqlupdate = "update voteDetails set voteNum=voteNum+1 where voteid= " & voteid & "and votedetailID= " & rbtnItems.SelectedValue.tostring & " "
'conn.Open()
'Dim cmd As New SqlCommand(sqlupdate, conn)
'cmd.ExecuteNonQuery()
'conn.Close()
Response.Write(sqlupdate) ‘这个我不知道vb.net怎么写

你把下面操作的全部注释掉

然后输出sql语句