我正在努力让公司的员工设置为“出席”。如果他们进入/退出程序。数据库有一个具有相同名称的字段,并使用布尔值来存储某人是否存在。我相信我的SQL语句是正确的。我继续得到的问题是:"附加信息:没有给出一个或多个必需参数的值。"
以下是我用来执行UPDATE查询的代码:
Private Sub btnClockout_Click(sender As Object, e As EventArgs) Handles btnClockout.Click
'SelectedEmployee = lstClockin.FocusedItem.Text
'lblClockinStatusColor.BackColor = Color.Red
'btnClockout.Enabled = False
'btnClockin.Enabled = True
'lblClockinStatus.Text = "Employee is: Clocked Out"
'If txtInfoEmployeeID.Text = "" Then
' MsgBox("You need to select a employee to clock-out.", MsgBoxStyle.Exclamation)
'End If
con.ConnectionString = provider & datafile
con.Open()
sqlstatement = ("UPDATE [EmployeeAccounts] SET [Present] = False WHERE [EmployeeID] = '" & SelectedEmployee & "'")
da = New OleDb.OleDbDataAdapter(sqlstatement, con)
da.Fill(ds, "ClockOutButton")
con.Close()
End Sub
答案 0 :(得分:0)
我认为SQL数据库中没有任何布尔类型。您可以使用以下代码。
Private Sub btnClockout_Click(sender As Object, e As EventArgs) Handles btnClockout.Click
SelectedEmployee = lstClockin.FocusedItem.Text
'lblClockinStatusColor.BackColor = Color.Red
'btnClockout.Enabled = False
'btnClockin.Enabled = True
'lblClockinStatus.Text = "Employee is: Clocked Out"
'If txtInfoEmployeeID.Text = "" Then
' MsgBox("You need to select a employee to clock-out.", MsgBoxStyle.Exclamation)
'End If
con.ConnectionString = provider & datafile
con.Open()
sqlstatement = ("UPDATE [EmployeeAccounts] SET [Present] = 'False' WHERE [EmployeeID] = '" & SelectedEmployee & "'")
da = New OleDb.OleDbDataAdapter(sqlstatement, con)
da.Fill(ds, "ClockOutButton")
con.Close()
End Sub