• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 111
  • Last Modified:

Launch stored procedure (SQL Server) from classic asp/VB page...

Hi there.

I have  this stored procedure as you can see here:


It has got a build in parameter Y/N whether it shall create/flush a table or not. How do I run the SP via VB code? And can I kinda build in the Y or N when launching it via VB?

Best regards

2 Solutions
Ryan ChongCommented:
here is an example:

Calling a Stored Procedure using ADO in a VBScript

try remove the server. when you declare your object.

Set cn = Server.CreateObject("ADODB.Connection")
   Set cmd = Server.CreateObject("ADODB.Command")
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I looked on your previous question and that only links to another question.  It is too confusing to help like this. The best thing is to add your actual code in the question here. Just post in the next comment.  

Otherwise, a quick example

Set cmd = Server.CreateObject("ADODB.Command")
With cmd
   ' Set up DB connection to use, set the type of SQL command
   	.ActiveConnection = connection_string
   	.CommandType = adCmdStoredProc
   	.CommandText = "stored_proc_name" '
   	.Parameters.Append .CreateParameter("@1",adVarWChar, adParamInput, 30)
   	.Parameters("@1") = variable

   set rs = .Execute
End With

  result= rs(0)

set cmd = nothing
set rs = nothing

Open in new window

The key is your establishing an output as a recordset and now you can access the return data just like any recordset you create.
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Scott has given you a good clear example. I just wanted to add one more thing. On the line:

.Parameters.Append .CreateParameter("@1",adVarWChar, adParamInput, 30)

you'll see two constants being used, adVarWChar and adParamInput. You will need to download and include the standard adovbs.inc file in order to define those constants.
Eugene ZCommented:
try this MSFT educational article with examples

How to call SQL Server stored procedures in ASP.NET by using Visual Basic .NET


or use EE another samples solutions ( unless you have already checked them)

like this one

or this

ullenulleAuthor Commented:
Hi guys.

Thank you for your input. I will check it out the next few days. I've been travelling.

Best regards

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now