Dim prm as adodb.parameter
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdStoredProc
.CommandText = "sp_AddItems"
Direction:=adParamInput, , Value:=Me.cboAreaID)
Direction:=adParamInput, Size:=50, Value:=Me.txtNewItem)
This assumes I've guessed right on the datatypes of your parameters in SQL
A cool shortcut to this, if you have ADO 2.6 (and, maybe, ADO 2.5, too), is
to execute your sproc as a method of the connection:
Dim cnn as adodb.connection
Set cnn = currentproject.connection
cnn.sp_AddItems Me.cboAreaID, Me.txtNewItem
Your way may work, too, if you use Zero for the index of your first
parameter instead of 1.
> I am trying to execute a stored procedure in SQL 7.0 database and I'm
> getting the following error:
> Below is my code:
> adocmd.ActiveConnection = CurrentProject.Connection
> adocmd.CommandType = adCmdStoredProc
> adocmd.CommandText = "sp_AddItems"
> adocmd.Parameters(1) = Me.cboAreaID
> adocmd.Parameters(2) = Me.txtNewItem
> any suggestions.