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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

execute stored procedure from vbscript 1

Status
Not open for further replies.

washaw

Programmer
Feb 13, 2008
48
Hi,

I need to be able to execute a stored procedure from VBScript, the procedure has input parameter of integer type and output parameter of integer type aswell - can anyone give me any pointers with how to do it?

Thanks
 
It is just like doing a query in VBScript except that instead of a "SELECT * FROM XXXX" you would do "EXEC ProcedureName Parameter"

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
It kinda confusing for me, my procedure has output parameter and has to assign this output parameter on some other variable and use it later

any one has sample code

Thanks
 
Code:
Set objCommand = Server.CreateObject("ADODB.Command")
Set objParam = Server.CreateObject("ADODB.Parameter")
Set rsYourRecordSet = Server.CreateObject("ADODB.Recordset")


objCommand.ActiveConnection = YourConnectionString
objCommand.commandtext = [i]YourStoredProc [/i]
objCommand.CommandType = 4   'defines cmd type as stored proc
Set objParm = objCommand.CreateParameter("[i]@SprocInputVar[/i]", 3,1,,[i]VBScriptInputVar[/i])          
objCommand.Parameters.Append objParm
Set objParm = objCommand.CreateParameter("[i]@SprocOutputVar[/i]", 3,2,,)
objCommand.Parameters.Append objParm 
set rsYourRecordSet = objCommand.Execute


'to access the output, assign to a variable

intSprocValue = objCommand.Parameters("[i]@SprocOutputVar[/i]")

that should do it for you.
 
THank you very much gryphon, that was a great help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top