Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate two tables on the same page with

Status
Not open for further replies.

jazzz

Technical User
Feb 17, 2000
433
US
different SQL statements from the same database can it be done?

I have been attempting to place two tables on my asp page and populate them dynamically with two seperate SQL statements from the same Access database but when I place the second table on the page it will not load. Can I make two connections from the same database or is this my problem? In otherwords I am using the same connection string but a different recordset. This is the first time I am attempting this so I need to learn the limitations of ADO and ASP.

Thanks in advance.

Life's a journey enjoy the ride...

jazzz
 
you can have single connection and two different recordsets...thats not a problem at all...can you post some code so that we can see whats going on

-DNG
 
Thank you DNG...Here is my include for the table that works the connection is in another include and we know it works.

This is an include at the top of my asp page.

<%
'this page is used with our models page and list the New models that are released.
Dim rs_NewReleases
Dim rs_NewReleases_numRows

Set rs_NewReleases = Server.CreateObject("ADODB.Recordset")
'handle any error that we may receive here before moving on
On error Resume Next
rs_NewReleases.ActiveConnection = MM_cnn_fmboxnumbers_STRING

If err.number <> 0 Then
Err.Clear
MM_cnn_fmboxnumbers_STRING.Close
Set MM_cnn_fmboxnumbers_STRING = Nothing
Set rs_NewReleases = Nothing
Response.Redirect("../error_messages/unavailable.htm")
Else
'do nothing
End If

'Retrieve New releases over the past 30 days.
Dim strSQLReleases

strSQLReleases="SELECT mint, newrelease, PartNum, Scale, amour, color FROM qry_new_releases WHERE new_release_date >= Date()-30 ORDER BY mint, newrelease DESC"

rs_NewReleases.Open strSQLReleases, MM_cnn_fmboxnumbers_STRING

rs_NewReleases_numRows = 0

Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rs_NewReleases_numRows = rs_NewReleases_numRows + Repeat1__numRows
%>

This is the table that uses it and it populates just fine.

<div id="new_releases_tbl"><!--New releases table begins here-->
<p>
Click on the part number to view an image and more information of any
replica.</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="Check out the latest releases from the Danbury Mint, Franklin Mint, GMP, CMC, WCPD and more.">
<caption align="left">
New Diecast Releases.
</caption>
<tr>
<th id="part#">Part #</th>
<th id="mint">Mint</th>
<th id="model">Model</th>
<th id="color">Color</th>
<th id="scale">Scale</th>
</tr>
<%
'populate the list here
While ((Repeat1__numRows <> 0) AND (NOT rs_NewReleases.EOF))
%>
<tr>
<td>
<%
'Get the model part number here.
Dim strmodelref
strmodelref=rs_NewReleases.Fields.Item("PartNum").value
response.write "<a href='preview_diecast.asp?PartNum=" & rs_NewReleases("PartNum") &"'>" & strmodelref & "</a>"
%></td>
<td><%=(rs_NewReleases.Fields.Item("mint").Value)%></td>
<td><%=(rs_NewReleases.Fields.Item("newrelease").Value)%></td>
<td><%=(rs_NewReleases.Fields.Item("color").Value)%></td>
<td>
<div align="center">
<%
'Place the scale info here.
Dim strscale

strscale=rs_NewReleases.Fields.Item("scale").Value

if strscale<> "" then
response.write strscale
else
response.write"&nbsp;"
end if
%>
</div></td>
</tr>
<%
'repeat all new models here.
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_NewReleases.MoveNext()
Wend

'close up and clear our dimension
'===============================================================================
MM_cnn_fmboxnumbers_STRING.Close
Set MM_cnn_fmboxnumbers_STRING = Nothing

rs_NewReleases.Close
Set rs_NewReleases = Nothing

%>
</table>
</div><!--End New Releases Table-->

Now when I place table two on the page I remove the close and nothing line for MM_cnn_fmboxnumbers_string.

What I want to do is duplicate the top but on the include I want the SQL to be this:

strSQLReviews="SELECT mint, newrelease, PartNum, Scale, amour, color FROM qrymodels WHERE review_date >= Date()-30 ORDER BY mint, newrelease DESC"

and then adjust the include and table accordingly. I just am not getting it. Brain must be dead...


Life's a journey enjoy the ride...

jazzz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top