I'm using VB6 against an SQL Server database.
I'm trying to return a value to the vb program after a stored procedure executes.
If the sp executes fine, I return a 1; if not, I return a 0.
I'm having trouble getting VB to read the output variable on the VB side.
I hard-coded in some data and the vb side won't recognize it.
Can anyone help?
Here's the sp:
CREATE PROCEDURE Test
@Client BIT OUTPUT
AS
SELECT version
FROM Agenda
WHERE AgendaDate = '1/31/01' AND Addendum = 0
PRINT 'Update Agenda'
UPDATE Agenda set version = version + 2147483647 WHERE AgendaDate = '1/31/01' AND Addendum = 0
SET @Client = 1
And here's the VB procedure that calls the sp:
loDBC.Open lsConnectStr
'testing 6/29
Set oDBCmd = New ADODB.Command
'Execute SQL Command using
With oDBCmd
'set connection object
.ActiveConnection = lsConnectStr
.CommandType = adCmdStoredProc
' set the name of the stored procedure
.CommandText = "Test"
' create and append the output parameter
.Parameters.Append .CreateParameter("@Client", adBSTR, adParamOutput)
' Execute the command with no records (no recordset returned)
.Execute , , adExecuteNoRecords
End With
' Get return value from stored procedure
vReturn = oDBCmd.Parameters("@Client"
MsgBox "Your Return Value Is: " & vReturn
'end testing 6/29
I'm still getting an empty return value on the VB side.
Thanks in advance.
John
I'm trying to return a value to the vb program after a stored procedure executes.
If the sp executes fine, I return a 1; if not, I return a 0.
I'm having trouble getting VB to read the output variable on the VB side.
I hard-coded in some data and the vb side won't recognize it.
Can anyone help?
Here's the sp:
CREATE PROCEDURE Test
@Client BIT OUTPUT
AS
SELECT version
FROM Agenda
WHERE AgendaDate = '1/31/01' AND Addendum = 0
PRINT 'Update Agenda'
UPDATE Agenda set version = version + 2147483647 WHERE AgendaDate = '1/31/01' AND Addendum = 0
SET @Client = 1
And here's the VB procedure that calls the sp:
loDBC.Open lsConnectStr
'testing 6/29
Set oDBCmd = New ADODB.Command
'Execute SQL Command using
With oDBCmd
'set connection object
.ActiveConnection = lsConnectStr
.CommandType = adCmdStoredProc
' set the name of the stored procedure
.CommandText = "Test"
' create and append the output parameter
.Parameters.Append .CreateParameter("@Client", adBSTR, adParamOutput)
' Execute the command with no records (no recordset returned)
.Execute , , adExecuteNoRecords
End With
' Get return value from stored procedure
vReturn = oDBCmd.Parameters("@Client"
MsgBox "Your Return Value Is: " & vReturn
'end testing 6/29
I'm still getting an empty return value on the VB side.
Thanks in advance.
John