• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 857
  • Last Modified:

An exception occurred: 'RS.open'

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
khongkham
Asked:
khongkham
  • 8
  • 4
  • 3
  • +6
1 Solution
 
Michel SakrCommented:
can you post more code
0
 
ArielBCommented:
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
 
khongkhamAuthor Commented:
----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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
khongkhamAuthor Commented:
error occurred on this line:

RS.Open sql, db
0
 
_marko_Commented:
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
 
weesiongCommented:
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
 
weesiongCommented:
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
 
khongkhamAuthor Commented:
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
 
weesiongCommented:
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
 
Michel SakrCommented:
prdId might be empty.. try to response.write the SQL variable..
0
 
khongkhamAuthor Commented:
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
 
khongkhamAuthor Commented:
sorry, the dim sconn should be strConn!


cheers,
khongkham
0
 
EDDYKTCommented:
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
 
edemcsCommented:
try using:
Set [variable] = [Connection Variable].Execute(RS)
0
 
Michel SakrCommented:
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
 
blue1914Commented:
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
 
EDDYKTCommented:
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
 
Michel SakrCommented:
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
 
Hornet241Commented:
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
 
khongkhamAuthor Commented:
hai, once i had done the testing will get back to u guys ASAP
0
 
khongkhamAuthor Commented:
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
 
khongkhamAuthor Commented:
sorry for my late reply, thanks a lot!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 4
  • 3
  • +6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now