[RESOLVED] -- Stored Procedure?
Using MSSQL 2k vb6/classic ado. I've search everywhere for a simple answer to this question from these forums to google. I have a simple sproc on my server with syntax as follows:
Code:
CREATE PROCEDURE [stp_Stop9Stat]
AS SELECT Val11 FROM tblConveyorB3 WHERE(Id=27)
GO
I don't want to create a recordset I just want the return value of field 'Val11' from my select statement. I can execute this in Query Analyzer and get the value for 'Val11'. How can I do this with ado? All I get is the @Return_Value which is 0 of course. I just want the stored procedure to return the value from my Select statement without creating a recordset object. Here is the code that executes the sproc from within vb.
Code:
Dim objCmd As New ADODB.Command
With objCmd
.CommandText = "stp_Stop9Stat"
.ActiveConnection = DbSQLConn
.CommandType = adCmdStoredProc
.Execute
End With
I know this is simple, but I can't seem to retrieve the value unless I build a recordset and set it to the Execute statement of my sproc? Am I looking at this wrong or can't I return a value from a sproc without using a recorset?
-jon
Re: Stored Procedure?[RESOLVED]
tg,
Thanks, that worked. I didn't realize I had to define parameters for field values. I though since the stored procedure returned a row of data I could reference it like a recordset. Adding the OUTPUT parameter worked like a charm! Thanks again.
-jon