0
美好的一天,我有以下代码:语法错误在更新语句在我的代码
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim cmd As New OleDb.OleDbCommand
Dim compDate As Date
Dim x As New Integer
Dim profID As New Integer
Dim date1 As New Date
compDate = Format(Date.Now, "hh:mm:ss, tt")
'MsgBox(compDate)
date1 = #8:00:00 AM#
profID = 201400001
x = 1
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
cmd.Connection = cnn
'Timer1.Start()
Timer1.Interval = 5000
sp.Close()
Try
sp.Open()
Catch
sp.Close()
End Try
If TextBox1.Text = "201400001" Then
If DateDiff(DateInterval.Minute, date1, Date.Now) > 5 Then
MsgBox("been here")
cmd.CommandText = "UPDATE test " & _
"SET ProfLog" & x & "" & _
"WHERE ProfID='" & Me.TextBox1.Text & "' AND ProfTime=#" & date1 & "#"
cmd.ExecuteNonQuery()
MsgBox("Did this")
End If
MsgBox("Done!")
ElseIf TextBox1.Text = "201400002" Then
MsgBox("Hello World Again!")
ElseIf TextBox1.Text = "201400003" Then
MsgBox("My Turn!")
End If
TextBox1.Clear()
End Sub
一旦达到cmd.ExecuteNonQuery,正在显示一个语法错误。它说,有一个“UPDATE语句中的语法错误”,我想知道什么是使我的程序出错的语法。提前致谢。
看起来好像在设置proflog列后有= =符号 – markg
SQL注入警告 - 此代码受SQL注入攻击。不要通过字符串连接来构建语句,而应考虑使用参数化查询。然后建立一个参数集合并用它执行查询。更安全。 – STLDeveloper
微软是一家大公司,而不是一门编程语言。如果您在这里需要帮助,您需要使用适当的标签,以便能够帮助您查看问题的人员。 –