We have the following stored procedure that runs fine in SQL Server 2000 Query Analyzer.
/*
** Retrieve next available Request ID
*/
CREATE procedure dbo.sp_GetRequestID2
@output int OUTPUT
as
/* begin transaction */
select @output = (select NextID from RequestID)
update dbo.RequestID set NextID = (NextID + 1)
/* commit */
Return 99
GO
However, when calling the proc from VB with the code below, we are not getting any results. Any ideas?
Dim strTest As String
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim param1 As Parameter
Dim param2 As Parameter
Set cmd = New ADODB.Command
cmd.ActiveConnection = "Provider=SQLOLEDB.1;Password=mypassword;Persist Security Info=True;User ID=myuser;Initial Catalog=HVDB;Data Source=TESTSERVER"
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_GetRequestID2"
' Set up a return parameter.
Set param1 = cmd.CreateParameter("Return", adInteger, adParamReturnValue)
cmd.Parameters.Append param1
' Set up an output parameter.
Set param2 = cmd.CreateParameter("Output", adInteger, adParamOutput)
cmd.Parameters.Append param2
Set rs = cmd.Execute
strTest = cmd(1)
Thanks!
/*
** Retrieve next available Request ID
*/
CREATE procedure dbo.sp_GetRequestID2
@output int OUTPUT
as
/* begin transaction */
select @output = (select NextID from RequestID)
update dbo.RequestID set NextID = (NextID + 1)
/* commit */
Return 99
GO
However, when calling the proc from VB with the code below, we are not getting any results. Any ideas?
Dim strTest As String
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim param1 As Parameter
Dim param2 As Parameter
Set cmd = New ADODB.Command
cmd.ActiveConnection = "Provider=SQLOLEDB.1;Password=mypassword;Persist Security Info=True;User ID=myuser;Initial Catalog=HVDB;Data Source=TESTSERVER"
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_GetRequestID2"
' Set up a return parameter.
Set param1 = cmd.CreateParameter("Return", adInteger, adParamReturnValue)
cmd.Parameters.Append param1
' Set up an output parameter.
Set param2 = cmd.CreateParameter("Output", adInteger, adParamOutput)
cmd.Parameters.Append param2
Set rs = cmd.Execute
strTest = cmd(1)
Thanks!