T
Tersia Ehlert
Hi
New in ADO.NET
I get an error "Must declare the variable '@pLastWorkingDay'." when my code
gets to "lrstResign.UpdateCommand.ExecuteNonQuery()"
What is missing?
See code below:
Dim lcnnVision As New System.Data.OleDb.OleDbConnection
Dim lcmdVision As New System.Data.OleDb.OleDbCommand
Dim lrstResign As New System.Data.OleDb.OleDbDataAdapter
lcnnVision.ConnectionString = lstrConnectionStringVision
lcnnVision.Open()
lcmdVision.Connection = lcnnVision
lcmdVision.CommandText = "Update Employees SET emTermDate=@pLastWorkingDay
WHERE [emEmployeeCode] = '" & txtVisionCode.Text & "'"
Dim paramLastWorkingDay As New System.Data.OleDb.OleDbParameter
paramLastWorkingDay.ParameterName = "pLastWorkingDay"
paramLastWorkingDay.OleDbType = OleDb.OleDbType.DBDate
paramLastWorkingDay.Value = K2calLastWorkingDay.SelectedDate
lcmdVision.Parameters.Add(paramLastWorkingDay)
lrstResign.UpdateCommand = lcmdVision
lrstResign.UpdateCommand.ExecuteNonQuery()
New in ADO.NET
I get an error "Must declare the variable '@pLastWorkingDay'." when my code
gets to "lrstResign.UpdateCommand.ExecuteNonQuery()"
What is missing?
See code below:
Dim lcnnVision As New System.Data.OleDb.OleDbConnection
Dim lcmdVision As New System.Data.OleDb.OleDbCommand
Dim lrstResign As New System.Data.OleDb.OleDbDataAdapter
lcnnVision.ConnectionString = lstrConnectionStringVision
lcnnVision.Open()
lcmdVision.Connection = lcnnVision
lcmdVision.CommandText = "Update Employees SET emTermDate=@pLastWorkingDay
WHERE [emEmployeeCode] = '" & txtVisionCode.Text & "'"
Dim paramLastWorkingDay As New System.Data.OleDb.OleDbParameter
paramLastWorkingDay.ParameterName = "pLastWorkingDay"
paramLastWorkingDay.OleDbType = OleDb.OleDbType.DBDate
paramLastWorkingDay.Value = K2calLastWorkingDay.SelectedDate
lcmdVision.Parameters.Add(paramLastWorkingDay)
lrstResign.UpdateCommand = lcmdVision
lrstResign.UpdateCommand.ExecuteNonQuery()