Solved

An exception occurred: 'RS.open'

Posted on 2001-06-08
22
848 Views
Last Modified: 2012-05-05
sometimes, this error will occurred on and off. but, sometimes it is working perfectly, no error!

does anyone know y is it so?

Error Type:
Microsoft VBScript runtime (0x800A01FB)
An exception occurred: 'RS.open'
/alai/backoffice/product/product.asp, line 119


thanks




0
Comment
Question by:khongkham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 3
  • +6
22 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6167022
can you post more code
0
 

Expert Comment

by:ArielB
ID: 6167056
In my experience it means that the recordset is empty and therefore cannot be operated on. to avoid this I usually chekc if RS.EOF is true before doing anything
0
 

Author Comment

by:khongkham
ID: 6167087
----product.asp----
<%@ LANGUAGE = "VBScript" %>
<!-- #include file="db.asp" -->

prdId = trim(request.querystring("prdId"))

sql = "select * from product where prdId = " & prdId

RS.Open sql, db
     
echo sql 'for debugging purpose

Do while not RS.eof                    

  'prdId = RS("prdId")
  prdA = RS("prdA")
  prdB = RS("prdB")
  prdC = RS("prdC")
  prdD = RS("prdD")
  prdE = RS("prdE")

  RS.MoveNext
loop
               
RS.Close
----end---

the RS is created in file: db.asp

----db.asp---
set RS = server.createobject("ADODB.Recordset")
---end---
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:khongkham
ID: 6167099
error occurred on this line:

RS.Open sql, db
0
 
LVL 2

Expert Comment

by:_marko_
ID: 6167144
This might not help but it won't hurt to try. Destroy the recordset after you've used and closed it with

Set RS = Nothing

Another thing you could try is to use an if-case to test the prdId:

If prdId <> "" Then
   sql = "SELECT"
   RS.Open ...
   and so on
End If

Defensive programming...

-Marko
0
 
LVL 7

Expert Comment

by:weesiong
ID: 6167184
khongkham,


<%@ LANGUAGE = "VBScript" %>
<!-- #include file="db.asp" -->
<%
set rs = Server.CreateObject("ADODB.Recordset")
prdId = trim(request.querystring("prdId"))
sql = "select * from product where prdId = " & prdId
RS.Open sql, db
.
.
.
%>

Regrads,
Wee Siong
   
0
 
LVL 7

Expert Comment

by:weesiong
ID: 6167195
khongkham,

Sorry, try this:

<%
set conn=server.CreateObject("adodb.connection")
conn.Open "Provider=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&Server.MapPath("yourdatbase.mdb")
set rs = Server.CreateObject("ADODB.Recordset")
prdId = trim(request.querystring("prdId"))
sql = "select * from product where prdId = " & prdId
RS.Open sql, conn
.
.
.
%>

Regards,
Wee Siong
0
 

Author Comment

by:khongkham
ID: 6167208
hai, marko
i had added in set RS = nothing          
but, this part i need a lot of testing which i may not be able to know is this error has been fixed!


but, later on if i m sure with i'll accept ur answer and give u the point!


thanks a lot!
0
 
LVL 7

Expert Comment

by:weesiong
ID: 6167230
khongkham,

You are no define what database you want to open, see the last code i posted in here. please define db as a Connection String.....

Regards,
Wee Siong
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6167233
prdId might be empty.. try to response.write the SQL variable..
0
 

Author Comment

by:khongkham
ID: 6167357
hai, the db connection is setted in db.asp

---db.asp---
<%
dim db
dim sconn
dim RS

Set db = Server.CreateObject("ADODB.Connection")

strConn "Provider=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&Server.MapPath("yourdatbase.mdb")

set RS = server.createobject("ADODB.Recordset")

'to open database connection
db.open strConn
%>

---end---

then, the product.asp included this db.asp

----product.asp----
<%@ LANGUAGE = "VBScript" %>
<!-- #include file="db.asp" -->

prdId = trim(request.querystring("prdId"))

sql = "select * from product where prdId = " & prdId

RS.Open sql, db
   
echo sql 'for debugging purpose

Do while not RS.eof                    

 'prdId = RS("prdId")
 prdA = RS("prdA")
 prdB = RS("prdB")
 prdC = RS("prdC")
 prdD = RS("prdD")
 prdE = RS("prdE")

 RS.MoveNext
loop
             
RS.Close
set RS = nothing          'added this

----end---


BUT, same error still ocurring!!!

hhmm..., the prdId shouldn't be empty... coz it's working perfectly sometimes!!!
will check it later!
0
 

Author Comment

by:khongkham
ID: 6167367
sorry, the dim sconn should be strConn!


cheers,
khongkham
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 20 total points
ID: 6167463
Try this

<%@ LANGUAGE = "VBScript" %>
<!-- #include file="db.asp" -->

Dim Count    <------
On error resume next  <-------
prdId = trim(request.querystring("prdId"))

sql = "select * from product where prdId = " & prdId

RS.Open sql, db
   
echo sql 'for debugging purpose

Count = 0          <------
Count = rs.recordcount          <------
if (Count > 0) then          <------
Do while not RS.eof                    

'prdId = RS("prdId")
prdA = RS("prdA")
prdB = RS("prdB")
prdC = RS("prdC")
prdD = RS("prdD")
prdE = RS("prdE")

RS.MoveNext
loop
RS.Close
set RS = nothing          'added this

End if          <------
           
0
 
LVL 8

Expert Comment

by:edemcs
ID: 6167606
try using:
Set [variable] = [Connection Variable].Execute(RS)
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6167817
you are not closing the database connection.. add this at the end:

db.close : set db=nothing

The thing that might be happening with you is that the maximum amount of connection is reached and the error fires until a connection times out then you don't get the error again..
0
 

Expert Comment

by:blue1914
ID: 6167846
Try printing out the SQL string that you are attempting to run and running it in your database first-that error is sometimes typical of having an invalid SQL string or an error in the statement.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 6167849
Silver5,

I've been told or read from somewhere that VB will do the gargage collection for you if it is local variable.

You don't have to specific to set object to nothing. When the routine is out of scope, the vb internal will free up memory.

Is that true?

0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6167866
in web developement you do it to free up resources immediately since a session times out after a while (sometimes it never times out) and system resources are crytical on web servers..


0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6169997
You could try adding this just before the Rs.Open Statement

     If Rs.State = 1 then Rs.Close

the error could be cause by the record set already being opened.

0
 

Author Comment

by:khongkham
ID: 6179821
hai, once i had done the testing will get back to u guys ASAP
0
 

Author Comment

by:khongkham
ID: 6184454
hai, i just wondering that is it all the RS and db conn should be closed and setted to nothing? can't i just leave it open? if i din close the RS n db conn, will it slow down the system performance? or will it be faster if i closed it and the open it again?

but, as for the db conn i need to use it all the pages... is there a need to close the db conn and set it to nothing and then open it again??
0
 

Author Comment

by:khongkham
ID: 6229959
sorry for my late reply, thanks a lot!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jquery to restrict certain words from input in form 11 52
Executing a script on a timer online 5 45
My Do While is Not Producing Anything 15 88
Getting robots.txt Error 9 57
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question