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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big MontyWeb Ninja at largeCommented:
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 file in order to define those constants.
EugeneZ ZhitomirskySQL SERVER EXPERTCommented:
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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.