Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How can I merge a query?


Message #1 by "James Taylor" <jamestaylor@t...> on Fri, 17 Nov 2000 15:49:01 -0000
I would like to merge two querys on the same page. I tried running them

together and then closing the connection, it didn't work so I am opening

the connection and closing it twice. I know there has to be a better way

than pounding the engine with two seperate requests. Code Follows:

********************************************

<html>

<!--#include file=incltop.asp-->



<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 1</title>

</head>



<body>

<%

Response.Buffer = True

  Dim strUserName

strUserName = Request.Form("BROKERNumber")

 Session("User") = Request.Form("BROKERNumber")

  %>



      <%

  On ERROR Resume Next

  

  

'Search and display the brokers name

whichDSN="DSN=rev1;uid=Admin;pwd="

mySQL="select FirstName,LastName from Ntwebusers where POINTName='"&

Request.Form("BrokerNumber") & "'"



set conntemp=server.createobject("adodb.connection")

conntemp.open whichDSN

set rstemp=conntemp.execute(mySQL)

If  rstemp.eof then

   response.write "Sorry<br>"

   response.write mySQL & "<br>you are not in our system..."

   Call CloseAll

   response.end

end if

response.write "<table border='0' width='10%' align='left' bgcolor='#339933'>"

'Put Headings On The Table of Field Names

'for each whatever in rstemp.fields

   'response.write "<tr><td><b>" & whatever.name & "</B></TD></tr>"

'next



response.write "<tr><td>"

response.write "Hello "

response.write " "

response.write rstemp.getstring(,, "</td><td>", "</td></tr><TR><TD>", "-null-")

response.write "</td></tr></table>"



Call CloseAll





SUB CloseALL

   rstemp.close

   set rstemp=nothing

   conntemp.close

   set conntemp=nothing

END SUB





'Search and display loans that belong to this lo xxxxxxxxxxxxxxxxxxxx

clwhichDSN="DSN=rev1;uid=Admin;pwd="

clSQL="select BorrowerFirstName, BorrowerLastName, LoanStatus from status

where BrokerNumber='"& Request.Form("BrokerNumber") & "'"



set clconntemp=server.createobject("adodb.connection")

clconntemp.open clwhichDSN

set clrstemp=clconntemp.execute(clSQL)

If  clrstemp.eof then

   response.write "You don't have any active loans"

   response.write clmySQL & "  in the system..."

   Call CloseAll

   response.end

end if

response.write"<br>"

response.write "<br>You have the following loans in the system:<br>"

response.write "<table border='0' width='50%' div align='left'>"

'Put Headings On The Table of Field Names

'for each whatever in clrstemp.fields

   'response.write "<tr><td><b>" & whatever.name & "</B></TD></tr>"

'next

response.write "<tr><td>"

response.write clrstemp.getstring(,, "</td><td>", "</td></tr><tr><td>", "-null-")

response.write "</tr></td></table>"



Call CloseAll2





SUB CloseALL2

   clrstemp.close

   set clrstemp=nothing

   clconntemp.close

   set clconntemp=nothing

END SUB

%>



 



</body>



</html>

******************************************

Thanks!

JamesT

Jamestaylor@t...


  Return to Index