Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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
 
Old May 31st, 2005, 07:45 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Recordset problem


'Assume objconn is declared

dim objRSPD
set objRSPD = server.createobject("ADODB.Recordset")
objRSPD.open "select * from Projectdetails",objConn

dim objRSWT
set objRSWT = server.createobject("ADODB.Recordset")
objRSWT.open "select * from worktype where wtid = " & objRSPD("wtid"),objConn

<table border="1">
<% do while not objRSPD.EOF %>
<tr align="center">
<% Response.write "<td>" & objRSPD("ProjID") & "</td>" %>
<% Response.write "<td>" & objRSWT("wtname") & "</td>" %>
</tr>
<% objRSPD.MoveNext
    objRSWT.close

    objRSWT.open "select * from worktype where wtid = " & objRSPD("wtid"),objConn
'''''This gives error. "Exception occurred"


    loop
%>

 
Old May 31st, 2005, 08:58 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

I think the problem is with the following code:

dim objRSWT
set objRSWT = server.createobject("ADODB.Recordset")
objRSWT.open "select * from worktype where wtid = " & objRSPD("wtid"),objConn

Here, u are not getting values in objRSPD recordset, which is used above.
You need to check for EOF and then execute the above statement.




Om Prakash
 
Old May 31st, 2005, 10:10 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Hi,

I have checked values of objRSPD, and that shows the value. Even I am getting values when I showed them in following statement:-
--------
<% Response.write "<td>" & objRSPD("ProjID") & "</td>" %>
--------
The only problem I think is with same recordset opeing again, which I don't know how to achieve.
Please let me know if you have can solve this out.

 
Old June 1st, 2005, 01:07 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

 Try adding the objRSPD.MoveNext statement after opening and closing objRSWT recordset.

something like:

do while not objRSPD.EOF %>
<tr align="center">
<% Response.write "<td>" & objRSPD("ProjID") & "</td>" %>
<% Response.write "<td>" & objRSWT("wtname") & "</td>" %>
</tr>
<% objRSWT.open "select * from worktype where wtid = " & objRSPD("wtid"),objConn
    objRSWT.close
  objRSPD.MoveNext
    loop



Om Prakash
 
Old June 1st, 2005, 03:46 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Well, If I move MoveNext stat after openning objRSWT, it will not update the value of ojbRSPD("wtid") which is given in open state of objRSWT and hence it is useless.
-------------
Let me brief you.

objRSPD contains one ID which keeps on changing(as we fire movenext) and hence we will get different values in objRSWT.

Please let me know if you have any idea about it.


 
Old June 1st, 2005, 03:57 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Rupen,

In the last iteration of your do loop, objRPSD is going to be at .EOF and you are trying to get a value from it when opening objRSWT. Can't you open objRSWT at the beginning of your loop rather than outside it and at the end, e.g.
Code:
<% do while not objRSPD.EOF 
    objRSWT.open "select * from worktype where wtid = " & objRSPD("wtid"), objConn     
    %>
    <tr align="center">
    <% Response.write "<td>" & objRSPD("ProjID") & "</td>" %>
    <% Response.write "<td>" & objRSWT("wtname") & "</td>" %>
    </tr>
    <% objRSPD.MoveNext
    objRSWT.close
loop
%>
HTH,

Chris
 
Old June 1st, 2005, 02:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

That should be fine now. Is that resolved?

_________________________
- Vijay G
Strive for Perfection
 
Old June 2nd, 2005, 11:03 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Hi Crhis,

Ya it is working as you mention.

Thank You so much!!!!







Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with recordset rwahdan BOOK: Access 2003 VBA Programmer's Reference 1 March 13th, 2008 05:03 AM
Recordset Problem hugoscp Classic ASP Professional 0 July 10th, 2007 05:59 AM
recordset problem jdsflash ASP.NET 1.0 and 1.1 Basics 1 May 16th, 2006 11:49 AM
Problem with recordset am_po_28 Pro VB 6 1 August 25th, 2003 10:17 AM





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