473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Stored procedure problem in Classic ASP

50
I am trying to execute the code below. When I execute the exact same code in the Query Analyzer, I get 6 records so there are records to be found. But when I try to do it through ASP, I get Error Number 3704:

ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.

I used the same connection string to execute other stored procedures with this user id without problem in this database. For some reason it is dying here.

The user id has execute rights on this procedure.

I’ve already spent half a day trying to get this snippet to work right. If I had any hair left, I would be pulling it out.

Any help would be appreciated.

Ramon

Here’s the code:
Expand|Select|Wrap|Line Numbers
  1. Dim Connection
  2. Dim ConnString
  3. Dim rs
  4. Dim SQL
  5. Dim b_Error
  6.  
  7. ConnString = "Provider=sqloledb;Data Source=<demo>;" & _
  8. "Network Library=DBMSSOCN;Initial Catalog=<demo>;" & _
  9. "User ID=<demo>;Password=<demo>;"
  10.  
  11. Set Connection = Server.CreateObject("ADODB.Connection")
  12. Set rs = Server.CreateObject("ADODB.Recordset")
  13.  
  14. Connection.Open ConnString
  15.  
  16. b_Error = False
  17. On Error Resume Next
  18. rs.Open "exec <demo>.dbo.txp_report_contract_set 2672,'N00104-02-G-0600-5036'",Connection
  19. response.write "1 b_Error=" & b_Error & "<br>" & Err.number & "<br>"
  20.  
  21. If rs.EOF = True Then 
  22. 'Just tests to see if rs.EOF = True causes an error which is captured below.
  23. End If
  24.  
  25. If Err.number <> 0 then
  26. b_Error = True
  27. End If
  28. response.write "2 b_Error=" & b_Error & "<br>" & Err.number & "<br>"
  29. response.end
Aug 13 '08 #1
7 9303
jeffstl
432 Expert 256MB
OK.

First rename your connection.

"Connection" is probably not a good name because I think it is a reserved word for vbscript.

Rename it to MyConn or something.....

Try that.

If that doesnt work let me know, and also please tell me which line this error is occurring on.
Aug 13 '08 #2
Krandor
50
I changed the code to MyConnection but I get the same result.

The error happens between
response.write "1 b_Error=" & b_Error & "<br>" & Err.number & "<br>"
where Err.number =0

response.write "2 b_Error=" & b_Error & "<br>" & Err.number & "<br>"
where Err.number = 3704

I put the If rs.EOF = True Then code to precipitate an error if there is an empty recordset. I tried rs.BOF and still get the same results.

The point is that the stored procedure should be generating results (6 records), but I am getting this empty recordset error instead.
Aug 13 '08 #3
jeffstl
432 Expert 256MB
This is not the error of an empty recordset

ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed


If that is the error you are getting something else is wrong here.

This code should prevent the application from crashing which you have in there.
Expand|Select|Wrap|Line Numbers
  1. if RS.EOF = True then
  2.      'captured
  3.      response.write "No Records"
  4.      response.end
  5. end if
  6.  
So if you are getting "Operation is not allowed when the object is closed" what line is that happening on?

If I am misunderstanding and the only problem is that you have an empty recordset, then I can only say there is something wrong with the stored procedure, or something different about executing the procedure outside the application.

I can't tell you with what you have supplied why your stored procedure is returning 0 records. Especially since I can't see the SP , nor the tables effected.
Aug 13 '08 #4
Krandor
50
The error is happening on the If rs.Eof = True statement.

It does the execute sql fine without generating an error but when I try to do anything with the results it generates the error that acts as if the recordset was not created in the first place.

So while you are correct that the error does not relate to an empty recordset, the effect works out to be the same.

I can post the stored procedure if you like, but it is going to be a lot of code.
Aug 13 '08 #5
jeffstl
432 Expert 256MB
Well before you do that lets try to isolate the problem

We can do this by replacing your stored procedure (and nothing else) with an SQL string.

Expand|Select|Wrap|Line Numbers
  1. 'Instead of stored procedure do this
  2. dim TestSQL
  3. TestSQL = "Select * from AnyTable"
  4.  
  5. RS.Open TestSQL,MyConnection
  6.  
  7. if RS.EOF then
  8.      'same problem still exists
  9. else
  10.      'there MUST be some kind of problem with running the SP from the app
  11. end if
  12.  
Basically just pass a simple SQL string instead of the SP. See if there are any problems.

If you get records back, then the problem is NOT in your code but is either a environment problem (can't run SP for some reason from app) or the way the SP is called , etc.

It sounds obvious but this is an easy way to point directly to the SP or the application environment as the problem area rather then the code.
Aug 13 '08 #6
Krandor
50
Looking at the stored procedure I see that it has a temporary table.

A. Can I make a single SQL stament that has a temporary table? Never tried it before.

B. I have had problems before with this id and stored procedures that had temporary tables. So this could be the crux of the problem.

As I understand it, temporary table are created in the master database. Does the id need some special permissions there to be able to create temporary tables?
Aug 14 '08 #7
jhardman
3,406 Expert 2GB
A. Can I make a single SQL stament that has a temporary table? Never tried it before.
you can't do exactly the same thing, but you can approximate it. give more details of how your temp table is set up and I will try to give pointers.
As I understand it, temporary table are created in the master database. Does the id need some special permissions there to be able to create temporary tables?
quite possibly you need read write and create permissions.

Jared
Aug 14 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Racer-D | last post by:
When some of the SQL Server stored procedures I have written are called via my Classic ASP page I have written I get the following error in the cell that is supposed to be retrieving a single...
4
by: Mullin Yu | last post by:
i have a stored procedure at sql server 2k. which will update records and select result from temp table. if i use SqlConnection class, and i do both. but, if i use OleDbConnection class, i can...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
1
by: John Hoge | last post by:
Is it possible to pass a null value to a stored procedure in .net? I have a search Sproc that can take one of two numbers to search on, but not both. I use the code below to pass a null value to...
2
by: Bari Allen | last post by:
ASP Classic question: I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First...
6
by: Catalin Porancea | last post by:
Hello, How can I execute a stored procedure through a odbc command? My stored procedure only modifies data in db, it doesn't returns any rows and doesn't use any parameter. Thank you
4
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier...
1
by: central_scrutinizer | last post by:
I have an ASP that has been working fine for several months, but it suddenly broke. I wonder if windows update has installed some security patch that is causing it. The problem is that I am...
1
JamieHowarth0
by: JamieHowarth0 | last post by:
Hi folks, Major bugbear - I've just written a stored procedure as part of a challenge-response authentication system in classic ASP and VB. I won't post all my code but basically part of the...
3
by: Dooza | last post by:
Hi there, I have a Stored Procedure in SQL 2000 that takes 10 input paremeters, and outputs 11 recordsets, not rows, but 11 different SELECT statements. The purpose of this is to for a menu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.