SQL Server - Getting a return value from a Stored Procedure (VBScript)

Asked By Ryan on 06-Feb-14 11:06 AM
I have a button on a form that calls a stored procedure. It comes back with a variable called return_value

I would like to call that back to the form in VBScript to display it in a text box...

Here is what I have so far and it works great. I'm struggling with the returnvalue

Sub CommandButton1_Click

dim sServer, sConn, oConn, sDatabaseName, sUser, sPassword
sDatabaseName="test_app"
sServer="XXXXXXXXXXXXX"
sUser="sa"
sPassword="XXXXXXXXXXXXX"
sConn="provider=sqloledb;data source=" & sServer & ";initial catalog=" & sDatabaseName
Set oConn = CreateObject("ADODB.Connection")
oConn.Open sConn, sUser, sPassword
oConn.Execute "exec spsoCopyDatesFromQuoteToSO '" +Form.Controls("txtSONum")+"'"
oConn.Close
Set oConn = Nothing

End Sub
Robbe Morris replied to Ryan on 06-Feb-14 01:40 PM
You can't use code like this (as well as the fact that your code is wide open to SQL injection attacks).  You need to use ADODB parameters.  Look towards the bottom of this article.

https://www.nullskull.com/articles/20030729.asp