Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Procedure Expects Parameter ...was not supplied

Status
Not open for further replies.

frmorris

Programmer
Aug 4, 2005
22
US
I have a datagrid that is suppose to update information in a sql database, but whenever I click the update button, I get the error below. The only two fields the user is allowed to update is the event and date field. Could someone help me. Thank you in advance.

I get the following error when I run the program.
Procedure 'update_tblevent' expects parameter '@event_3', which was not supplied.

Source Error:
Line 164: connEvent.Open()
Line 165: myCommand.ExecuteNonQuery()
Line 166: connEvent.Close()
Line 167: masterDataGrid.EditItemIndex = -1

My code

Dim eventid As Integer
Dim username As String

Dim strevent As String
Dim _event As TextBox = DirectCast(e.Item.FindControl("Textbox2"), TextBox)

Dim strdate As String
Dim _date As TextBox = DirectCast(e.Item.FindControl("Textbox1"), TextBox)

Dim myCommand As New SqlCommand("update_tblevent", connEvent)
myCommand.CommandType = CommandType.StoredProcedure

myCommand.Parameters.Add(New SqlParameter("@event_3", Data.SqlDbType.VarChar, 50))
myCommand.Parameters("@event_3").Value = strevent

myCommand.Parameters.Add(New SqlParameter("@date_4", Data.SqlDbType.DateTime))
myCommand.Parameters("@date_4").Value = strdate

connEvent.Open()
myCommand.ExecuteNonQuery()
connEvent.Close()
masterDataGrid.EditItemIndex = -1
BindGrid()
 
I am doing an insert from a stored procedure and use the following..

Dim txt As String = CType(e.Item.FindControl("txtName"), TextBox).Text

cmd.Parameters.Add(New SqlParameter("@DBField", txtField.Text))

using the above I don't think you would need this
"myCommand.Parameters("@date_4").Value = strdate"

or since it's a stored procedure you are already specifying the DBType in the Procedure. no need to do it here.




 
strevent doesn't look to be getting populated...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top