Hi!
Can somebody help me out please?
I need to modify the code, so that it uses the text command version of the parameterized sql/ access statement. Does anybody know how to do that?
Thank you!
Dim dtNW As New DataTable
Dim ConnEmp As OleDb.OleDbConnection
Dim strCommand As String = "Select LastName, FirstName, City from Employees where EmployeeID = " & txtID.Text
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\DataStore\Nwind.mdb;Mode=Share Deny None;"
ConnEmp = New OleDb.OleDbConnection(strConn)
Dim cmdEmp As New OleDb.OleDbCommand(strCommand, ConnEmp)
Dim daEmp As New OleDb.OleDbDataAdapter(cmdEmp)
Try
daEmp.Fill(dtNW)
txtLName.Text = dtNW.Rows(0).Item("LastName")
txtFName.Text = dtNW.Rows(0).Item("FirstName")
txtCity.Text = dtNW.Rows(0).Item("City").ToString ' City may be null
Catch exc As Exception
' There should not be msgbox in a Class
MsgBox("Error in retrieving Data " & exc.Message)
txtLName.Clear()
txtFName.Clear()
txtCity.Clear()
End Try
Can somebody help me out please?
I need to modify the code, so that it uses the text command version of the parameterized sql/ access statement. Does anybody know how to do that?
Thank you!
Dim dtNW As New DataTable
Dim ConnEmp As OleDb.OleDbConnection
Dim strCommand As String = "Select LastName, FirstName, City from Employees where EmployeeID = " & txtID.Text
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\DataStore\Nwind.mdb;Mode=Share Deny None;"
ConnEmp = New OleDb.OleDbConnection(strConn)
Dim cmdEmp As New OleDb.OleDbCommand(strCommand, ConnEmp)
Dim daEmp As New OleDb.OleDbDataAdapter(cmdEmp)
Try
daEmp.Fill(dtNW)
txtLName.Text = dtNW.Rows(0).Item("LastName")
txtFName.Text = dtNW.Rows(0).Item("FirstName")
txtCity.Text = dtNW.Rows(0).Item("City").ToString ' City may be null
Catch exc As Exception
' There should not be msgbox in a Class
MsgBox("Error in retrieving Data " & exc.Message)
txtLName.Clear()
txtFName.Clear()
txtCity.Clear()
End Try