Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output parameters & Return Values 1

Status
Not open for further replies.

salvatoredoria

Programmer
Jan 22, 2004
22
0
0
IT
i have a stored procudere in SQL Server and i have this problem:
The stored procedure has a return value (@codice0) that can be read with sql analyzer, but i don't know how to get the value in visual basic.
for example:
'
in Query Analyzer
'
declare @myid int
EXEC @myid=sp_Class001_Insert 01,'AGHI','AGHI',4,20040525,1227,0
SELECT @myid
'
returns the value
'
' In Visual Basic
'
Myconn.execute "sp_Class001_Insert,'AGHI','AGHI',4,20040525,1227,0"
with this statement i don't know how to get the return value.

Thanks to all
 
Use a recordset ...
strSQL="sp_Class001_Insert,'AGHI','AGHI',4,20040525,1227,0"

Rs.open strSql,Myconn,adOpenForwardOnly, adLockReadOnly

Debug.Print Rs.Fields(0).value

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
thank you for the hint.
But after executing the recordset it's been closed.
Any Other idea
 
thank you for the hint.
But after executing the recordset it's been closed.
Any Other idea ?
 
What do you mean closed... does it give you an error or does on the rs.open .... or does it give you an error if you try to get the .fields(0).value ???

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
If you only execute your stored proc in Q-Analyser without the declare @myid ... do you get results?

Try this ...

strSql = "declare @myid int EXEC @myid=sp_Class001_Insert 01,'AGHI','AGHI',4,20040525,1227,0 SELECT @myid"

Rs.open strSql,Myconn,adOpenForwardOnly, adLockReadOnly

Debug.Print Rs.Fields(0).value

If this works then you might consider including the @myid as an output paramter in your stored proc. (See BOL under output parameters .. lots of examples)

Cheers
[flowerface]






I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top