If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Problem calling stored procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-14-04, 05:44
Spiny Spiny is offline
Registered User
 
Join Date: Apr 2003
Posts: 4
Problem calling stored procedure

Any help on this would be much appreciated:

I have a stored procedure, say, on Northwind demo db like:

CREATE PROCEDURE up_CustCount @parm1 varchar(256) AS
Begin
select count(*) from customers
end
GO

and the following VB code:

Dim oCon As ADODB.Connection
Dim oCmd As ADODB.Command
Dim oParm As ADODB.Parameter
Dim oRS As ADODB.Recordset


Set oCon = New ADODB.Connection
oCon.Provider = "SQLOLEDB"
oCon.Properties("Integrated Security").Value = "SSPI"
oCon.Open "Server=(local);Database=Northwind"

Set oCmd = New ADODB.Command

Set oCmd.ActiveConnection = oCon
oCmd.CommandText = "up_CustCount"

Set oParm = oCmd.CreateParameter("@parm1", adVarChar, adParamInput, 256, "asas")
oCmd.Parameters.Append oParm

Set oRS = oCmd.Execute
MsgBox oRS.Fields(1)
oRS.Close
oCon.Close


I just get an error "Procedure 'up_CustCount' expects parameter '@parm1', which was not supplied."

But I have supplied it!

Can anyone help please?
Reply With Quote
  #2 (permalink)  
Old 01-14-04, 06:05
Spiny Spiny is offline
Registered User
 
Join Date: Apr 2003
Posts: 4
Oops

Found it.

forgot to set the command type to adCmdStoredProc.

/me shuffles.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On