Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Need urgent help with multiple recordsets


Message #1 by "Christopher Cote" <chrscote@9...> on Tue, 22 Oct 2002 01:21:27
I am having some problems with one of my ASP pages.  I am trying to create 
2 separate recordsets that contain data from 2 different tables, in order 
to display them.  I have been able to get the first recordset to display 
fine.  However, when I try to open the new recordset with a new query, I 
get an error that says the object doesn't like the property 'Open', or 
something to that effect.
  Here is a small snippet of what I did.

   dim objConn
   objConn = Server.createObject("ADODB.Connection")
   conn.open "DSN=Baseball"
   dim objRS
   objRS = Server.createObject("ADODB.Recordset")
   SQLStr = "SELECT * FROM Table1"
   objRS.open SQLStr, conn
   //Do some display with data from objRS

   objRS.close
   set objRS = nothing
   dim objRS2
   objRS2 = Server.createObject("ADODB.Recordset")
   strSQL = "SELECT * FROM Table2"
   objRS2.open strSQL, conn

   //Do some more display with data from objRS2

The error always occurs when I try to perform the last line 
(objRS2.open).  I do not know what I am doing wrong and would appreciate 
any and all help I can get.

Thank you,
Chris
Message #2 by "TomMallard" <mallard@s...> on Mon, 21 Oct 2002 18:57:25 -0700
Try this idea...uses the execute method of the connection object...

dim objConn
   objConn = Server.createObject("ADODB.Connection")
   conn.open "DSN=Baseball"
   dim objRS
   objRS = Server.createObject("ADODB.Recordset")
   SQLStr = "SELECT * FROM Table1"
   set objRS = objConn.execute(SQLStr)
   'Do some display with data from objRS
   strSQL = "SELECT * FROM Table2"
   set objRS = objConn.execute(strSQL)
   'mess with the second recordset

   objConn.Close()
   set objConn = nothing
   set objRS = nothing

tom mallard
seattle


-----Original Message-----
From: Christopher Cote [mailto:chrscote@9...]
Sent: Tuesday, October 22, 2002 1:21 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Need urgent help with multiple recordsets


I am having some problems with one of my ASP pages.  I am trying to create
2 separate recordsets that contain data from 2 different tables, in order
to display them.  I have been able to get the first recordset to display
fine.  However, when I try to open the new recordset with a new query, I
get an error that says the object doesn't like the property 'Open', or
something to that effect.
  Here is a small snippet of what I did.

   dim objConn
   objConn = Server.createObject("ADODB.Connection")
   conn.open "DSN=Baseball"
   dim objRS
   objRS = Server.createObject("ADODB.Recordset")
   SQLStr = "SELECT * FROM Table1"
   objRS.open SQLStr, conn
   //Do some display with data from objRS

   objRS.close
   set objRS = nothing
   dim objRS2
   objRS2 = Server.createObject("ADODB.Recordset")
   strSQL = "SELECT * FROM Table2"
   objRS2.open strSQL, conn

   //Do some more display with data from objRS2

The error always occurs when I try to perform the last line
(objRS2.open).  I do not know what I am doing wrong and would appreciate
any and all help I can get.

Thank you,
Chris

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


Message #3 by John Eix <jeix@s...> on Tue, 22 Oct 2002 13:24:19 -0400
Hi Chris

I  do what you seem to want to do all the time but I think you have to 
close the first recordset before you open the second, at least that is 
what I do, I use the first opening to populate a drop down select in a 
form, close it and then open another table from the same database file 
to populate another select box in a form, it works great because it 
eliminates input errors. I have included my e-mail address below if you 
would like me to send you some example code. I also tend to use querries 
on the data base rather than selects. TTYS John

.........................................
John Eix ]8-)
E-mail: jeix@s...
ECS web site: http://eix.dyndns.org/
The Twin's web site http://eix.dyndns.org/twins/
Holly's web site http://eix.dyndns.org/holly/
ChemEd Trading Post: http://eix.dyndns.org/tp/
Hamilton-Niagara Conference: http://eix.dyndns.org/hnc/
Mobile Phone:  xxx-xxx-xxxx
Phone:  xxx-xxx-xxxx
Eix Consulting Services
1345 Kensington Pk Rd
OAKVILLE, ON
L6H 2G8

Christopher Cote wrote:

>I am having some problems with one of my ASP pages.  I am trying to create 
>2 separate recordsets that contain data from 2 different tables, in order 
>to display them.  I have been able to get the first recordset to display 
>fine.  However, when I try to open the new recordset with a new query, I 
>get an error that says the object doesn't like the property 'Open', or 
>something to that effect.
>  Here is a small snippet of what I did.
>
>   dim objConn
>   objConn = Server.createObject("ADODB.Connection")
>   conn.open "DSN=Baseball"
>   dim objRS
>   objRS = Server.createObject("ADODB.Recordset")
>   SQLStr = "SELECT * FROM Table1"
>   objRS.open SQLStr, conn
>   //Do some display with data from objRS
>
>   objRS.close
>   set objRS = nothing
>   dim objRS2
>   objRS2 = Server.createObject("ADODB.Recordset")
>   strSQL = "SELECT * FROM Table2"
>   objRS2.open strSQL, conn
>
>   //Do some more display with data from objRS2
>
>The error always occurs when I try to perform the last line 
>(objRS2.open).  I do not know what I am doing wrong and would appreciate 
>any and all help I can get.
>
>Thank you,
>Chris
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>r-20
>
>
>  
>





Christopher Cote wrote:

>I am having some problems with one of my ASP pages.  I am trying to create 
>2 separate recordsets that contain data from 2 different tables, in order 
>to display them.  I have been able to get the first recordset to display 
>fine.  However, when I try to open the new recordset with a new query, I 
>get an error that says the object doesn't like the property 'Open', or 
>something to that effect.
>  Here is a small snippet of what I did.
>
>   dim objConn
>   objConn = Server.createObject("ADODB.Connection")
>   conn.open "DSN=Baseball"
>   dim objRS
>   objRS = Server.createObject("ADODB.Recordset")
>   SQLStr = "SELECT * FROM Table1"
>   objRS.open SQLStr, conn
>   //Do some display with data from objRS
>
>   objRS.close
>   set objRS = nothing
>   dim objRS2
>   objRS2 = Server.createObject("ADODB.Recordset")
>   strSQL = "SELECT * FROM Table2"
>   objRS2.open strSQL, conn
>
>   //Do some more display with data from objRS2
>
>The error always occurs when I try to perform the last line 
>(objRS2.open).  I do not know what I am doing wrong and would appreciate 
>any and all help I can get.
>
>Thank you,
>Chris
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>r-20
>
>
>  
>

-- 
......................................... 
John Eix ]8-) 
E-mail: jeix@s... 
ECS web site: http://eix.dyndns.org/
The Twin's web site http://eix.dyndns.org/twins/
Holly's web site http://eix.dyndns.org/holly/
ChemEd Trading Post: http://eix.dyndns.org/tp/
Hamilton-Niagara Conference: http://eix.dyndns.org/hnc/
Mobile Phone:  xxx-xxx-xxxx 
Phone:  xxx-xxx-xxxx
Eix Consulting Services
1345 Kensington Pk Rd 
OAKVILLE, ON 
L6H 2G8 



  Return to Index