Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2004, 02:32 AM
Authorized User
 
Join Date: Nov 2003
Location: Phnom Penh, , Cambodia.
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eapsokha
Default Reuse the recordset object

I want to a recordset object at least twice times; first for students, second for teacher and third for subjects as below:

objRecordset.Open "SELECT * FROM tbl_student", objConn
'list of students
objRecordset.Open "SELECT * FROM tbl_teacher", objConn
'list of teachers
objRecordset.Open "SELECT * FROM tbl_subject", objConn
'list of subjects

I may reuse the recordset of students in here too.

Can I do that? if so, how?

Many thanks


__________________
Mr. Sokha Eap
Webmaster
UNDP Cambodia
Reply With Quote
  #2 (permalink)  
Old February 21st, 2004, 08:27 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

That's fine although I think you need to close it in between:
Code:
objRecordset.Open "SELECT * FROM tbl_student", objConn
'list of students
'process data
objRecordset.close()
objRecordset.Open "SELECT * FROM tbl_teacher", objConn
'list of teachers
'process data
objRecordset.close()
objRecordset.Open "SELECT * FROM tbl_subject", objConn
'list of subjects
'process data
objRecordset.close()
--

Joe
Reply With Quote
  #3 (permalink)  
Old February 23rd, 2004, 02:53 AM
Authorized User
 
Join Date: Nov 2003
Location: Phnom Penh, , Cambodia.
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eapsokha
Default

How can I use the first one again, student recordset?

Thanks

Reply With Quote
  #4 (permalink)  
Old February 23rd, 2004, 03:25 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about a different approach to this? Provided that you are passing the RsType to the page.

RsType = request("RsType")

select case RsType
    case "Student"
        MySql = "select * from tbl_student"
    case "Teacher"
        MySql = "select * from tbl_teacher"
    case "Subject"
        MySql = "select * from tbl_subject"
    case else
        MySql = "select * from tbl_student"
end select

set rs = server.createobject("adodb.recordset")
sql = MySql
rs.open sql, objConn
if not rs.eof then
    do while not rs.eof
        response.write rs("Field")
    rs.movenext
    loop
end if
rs.close
set rs = nothing
Reply With Quote
  #5 (permalink)  
Old February 27th, 2004, 12:05 AM
Authorized User
 
Join Date: Nov 2003
Location: Phnom Penh, , Cambodia.
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eapsokha
Default

thanks for your guideline.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i populate datagrid from a recordset object bisigreat VB How-To 1 August 6th, 2009 04:30 AM
MSXML Object Reuse tclancy XSLT 0 April 27th, 2006 10:30 AM
Ouptut from object Recordset (ADO) AnneOlga Excel VBA 1 March 30th, 2006 06:17 AM
How do i populate datagrid from a recordset object bisigreat BOOK: ASP.NET Website Programming Problem-Design-Solution 1 September 22nd, 2004 11:35 AM
How Do I Reuse data from a RecordSet? steve456 Classic ASP Professional 2 October 21st, 2003 05:30 AM



All times are GMT -4. The time now is 07:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.