Solved

An exception occurred: 'RS.open'

Posted on 2001-06-08
22
844 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
  • 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now