| | |
Retrieving a field from a SQL procedure
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2004
Posts: 1
Reputation:
Solved Threads: 0
Hello all,
I have been working out of an older ASP/Visual Basic/SQL Server Developers Guide. My code is exactly as written in the book but I still can't seem to get the asp to collect the information from the Stored Procedure.
My asp page calls for the Procedure:
The Stored Procedure is this simple:
Then I call the information from my asp like this:
And that is where the error comes in.
I have tested the Procedure in SQL Analyzer and it returns idBasket with the correct number.
Any ideas?
Thanks,
Matt
I have been working out of an older ASP/Visual Basic/SQL Server Developers Guide. My code is exactly as written in the book but I still can't seem to get the asp to collect the information from the Stored Procedure.
My asp page calls for the Procedure:
ASP Syntax (Toggle Plain Text)
'check to see if a basket has been created if session("idBasket") = "" then set dbBasket = server.CreateObject("adodb.connection") set rsBasket = server.CreateObject("adodb.recordset") dbBasket.open "Provider=sqloledb;Data Source=(local);Initial Catalog=EcommerceDB;User Id=sa;Password=12511;" sql = "execute sp_CreateBasket " & session("idShopper") set rsBasket = dbBasket.Execute(sql)
ASP Syntax (Toggle Plain Text)
Create Procedure sp_CreateBasket @idShopper int AS Insert into basket(idShopper) values(@idShopper) Select idBasket = @@identity
ASP Syntax (Toggle Plain Text)
idBasket = rsBasket("idBasket")
•
•
•
•
Item cannot be found in the collection corresponding to the requested name or ordinal.
Any ideas?
Thanks,
Matt
Try this:
ASP Syntax (Toggle Plain Text)
if session("idBasket") = "" then 'Open DB set dbBasket = server.CreateObject("adodb.connection") dbBasket.open "Provider=sqloledb;Data Source=(local);Initial Catalog=EcommerceDB;User Id=sa;Password=12511;" set rsBasket = server.CreateObject("adodb.recordset") sql = "execute sp_CreateBasket idShopper=" & session("idShopper") rsBasket.Open sql, dbBasket idBasket = rsBasket("idBasket") 'Always close connections or server will suffer rsBasket.Close Set rsBasket = Nothing 'Close main connection dbBasket.Close set dbBasket = Nothing End If
![]() |
Similar Threads
- Accessing a field in SQL (MS SQL)
- Update Binary Field in sql server 2000 (Visual Basic 4 / 5 / 6)
- Help-->SQL Statement in vb6 for getting total of Field (Visual Basic 4 / 5 / 6)
- How to send email attachments from PL/SQL procedure (Oracle)
- using sql procedure (Java)
Other Threads in the ASP Forum
- Previous Thread: Search by Zip Radius
- Next Thread: getting email adress from logon_user
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7





