 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 28th, 2004, 06:28 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
trigger stored procedures from asp
Hello
I have searched the forums but havent really seen answer to mu question.
I am trying to trigger a stored procedure from an asp site. The stored procedure gets 2 variable (supposedly from the asp site) then it updates a field in a selected table. Could anyone help me out with a link or a sniplet please? thanx
|
|

June 28th, 2004, 08:32 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You can define your connection and recordset objects and trigger the procedure as shown below.
Code:
set Conn = Server.CreateObject("ADODB.CONNECTION")
Conn.Open "Your Connection string"
' For connection strings you can check Connection Strings
strSql = "Execute YourProcedure @StringParam1='" & StringParam1Value & "', @intParam2=" & intParam2Value
Conn.Execute(strSql)
In case you are returning a result from your Procedure, you can use the above red code as
Code:
Set Rs = Conn.Execute(strSql)
strResult=Rs("Result_That_You_Return_From_Proc")
Response.write strResult
Hope that helps.
Cheers!
_________________________
-Vijay G
 Strive for Perfection 
|
|

June 29th, 2004, 03:50 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Excelent. Thanx!
However...
I cant make it work.
I am using 3 parameters instead of 2. I use "centeralized" (lol) conn string which works fine for the rest of the asp pages.(those pages are successfully accessing/editing a table in the DB), but the stored proc triggering just dont work.
my sql str is something like this:
sql = "Execute docalc @num1='"&number1&"',@num2="&number2&"',@num3='"&nu mber3&"'"
Right after that I have an error report script.
I am getting " Unclosed quotation mark before the character string ',@num3=''."
or num3 is excepted by the procedure but havent ben included,
or just a syntax error.
I know its my bad putting the quotation marks to the wrong place, but so far I couldnt figure it out the correct way.
|
|

June 29th, 2004, 09:12 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
You are missing a single quote after @num2=
That's what's throwing it off.
Brian
|
|

June 29th, 2004, 09:18 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If you are passing numeric type(Int, Float, etc...) parameters, then you don't really have to use SINGLE QUOTEs around the variables. That can be used only when you pass on STRING type(VARCHAR, nVARCHAR, etc...) values.
Cheers!
_________________________
- Vijay G
 Strive for Perfection 
|
|

June 30th, 2004, 12:58 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanx for helping guys. Finally I got it to work this way:
set rsl = Server.CreateObject("ADODB.Recordset")
sql = "Execute docalc @num1='"& number1 &"', @num2='"& number2 &"', @num3='"& number3 &"'"
set rsl=conn.execute(sql)
|
|

July 6th, 2004, 01:47 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is good but u must use Command object for stored proc instead connection object coz command object is the best suit for storeproc
|
|

July 15th, 2004, 10:47 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
cool thanx, but what do you mean I should/must use command object? Could you explain it please?
|
|
 |