GolferGuy45
Member
- Joined
- Sep 24, 2008
- Messages
- 6
- Programming Experience
- 10+
Here is my code to setup the SqlCommand with a parameter:
The program fails at the "mySqlDataAdapter.Fill(myDataSet)" statement with this error message:
"Procedure or function 'AllSecurityRolesAndSelected' expects parameter '@EmployeeID', which was not supplied."
When I change the StoredProcedure to not look for this parameter, and hard code a valid EmployeeID into the StoredProcedure, and change the VB code to not try to pass a parameter, the StoredProcedure and VB are able to communicate, and the DataGrid on my form fills with the correct data.
I just have no idea why this code is not working to actually add the @EmployeeID parameter to the SqlCommand.
Any help with what I need to do would be greatly appreciated.
Vic
VB.NET:
Dim mySqlCommand As New SqlCommand()
Dim mySqlDataAdapter As New SqlDataAdapter()
mySqlCommand.CommandText = myCommandText
mySqlCommand.Connection = SecurityRolesConnection
mySqlCommand.Parameters.Add("@EmployeeID", SqlDbType.BigInt)
Long.TryParse(idTextBox.Text, myBigInt)
mySqlCommand.Parameters("@EmployeeID").Value = myBigInt
mySqlCommand.Prepare()
mySqlDataAdapter.SelectCommand = mySqlCommand
mySqlDataAdapter.Fill(myDataSet)
myTableView = myDataSet.Tables(0).DefaultView
"Procedure or function 'AllSecurityRolesAndSelected' expects parameter '@EmployeeID', which was not supplied."
When I change the StoredProcedure to not look for this parameter, and hard code a valid EmployeeID into the StoredProcedure, and change the VB code to not try to pass a parameter, the StoredProcedure and VB are able to communicate, and the DataGrid on my form fills with the correct data.
I just have no idea why this code is not working to actually add the @EmployeeID parameter to the SqlCommand.
Any help with what I need to do would be greatly appreciated.
Vic