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 February 28th, 2004, 03:00 PM
Registered User
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Working with data from 2 databases

Hello

I am pulling data from two tables (seperate databases)into two different recordsets. It is likely that some of the data will be duplicated information. What I would like to be able to do is filter out the duplicates and just present the first record. This is simply a string that is going to be passed via a querystring to another page.

What is the best approach? I have not been able to merge both recordsets into one to be able to remove the duplicates. Or am I thinking about this the wrong way?

Here is what I have now - can get the data ok, just can't get rid of duplicates to pass on only the first instance of a string.

<%

Set Rs = Server.CreateObject("ADODB.Recordset")
Set Conn=server.createobject("adodb.connection")
Conn.Open "DSN=Names;",,3

Set Rs2 = Server.CreateObject("ADODB.Recordset")
Set Conn2=server.createobject("adodb.connection")
Conn2.Open "DSN=Movies;",,3


    q= "SELECT * FROM table1 WHERE (First LIKE '%" & Request.Form("NameSearchtest") & "%' OR Last LIKE '%" & Request.Form("NameSearchtest") & "%') ORDER by first"

    x="SELECT * FROM name WHERE Name LIKE '%" & Request.Form("NameSearchtest") & "%' ORDER BY Name"


rs.Open (q), "DSN=Names;",3

rs2.Open (x), "DSN=Movies;",3

%>

<%while NOT rs.EOF

    first=rs("first")
    last=rs("last")

%>

<TABLE CELLSPACING=0 CELLPADDING=4 WIDTH=550>
<TD Width = "300">
<b><a href="star.asp?<%=rs("First")&" " & rs("Last")%>"><%=rs("First")& " " & rs("Last")%></a></small></b>
</td>
</table>

<%

rs.MoveNext
wend

while NOT rs2.EOF

name=rs2("Name")

%>
<TABLE CELLSPACING=0 CELLPADDING=4 WIDTH=550>
<TD Width = "300">
<b><a href="star.asp?<%=rs2("Name")%>"><%=rs2("Name")%></a></small></b>
</td>
</table>

<%
rs2.MoveNext
wend

rs.Close
Set rs = nothing
conn.Close
Set conn = nothing

rs2.Close
Set rs2 = nothing
conn2.Close
Set conn2 = nothing

%>
 
Old February 29th, 2004, 03:28 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you're getting the duplicates withing each recordset, try setting a value during your loop for the name, then check the name and only show the first instance. In this case I have used NamePass around your HTML table.

while NOT rs2.EOF

name=rs2("Name")

    if NamePass <> rs2("Name") then
%>

<TABLE CELLSPACING=0 CELLPADDING=4 WIDTH=550>
<TD Width = "300">
<b><a href="star.asp?<%=rs2("Name")%>"><%=rs2("Name")%></a></small></b>
</td>
</table>

<%
    end if
    NamePass = rs2("Name")

rs2.MoveNext
wend

If you're getting matches between the recordsets then that is a different story. You might try inserting records from both recordsets into a temp table and querying that.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Data From Multiple Databases Macsood SQL Language 4 January 24th, 2012 04:58 AM
Why data-type="number" not working here... akentanaka XSLT 6 July 12th, 2008 07:13 PM
transfer data to xls with ADO not working nebbish Access 4 March 1st, 2006 09:55 PM
Working with files instead of databases mehdi62b ASP.NET 1.0 and 1.1 Professional 4 August 19th, 2004 08:11 AM
working with data in DataSet fyeojo VS.NET 2002/2003 2 August 26th, 2003 01:17 AM





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