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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to Database problem

Status
Not open for further replies.

Dashsa

Programmer
Aug 7, 2006
110
US
Hello I am trying to connect to one database but get data from two tables I can get the data from one table with no problems but I cant seem to get the data from the second table...
here is the code:
Code:
<%@ language="JScript"%>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="script.js"></script>

<%
var moo = Request.Form("Location")
conn = Server.CreateObject("ADODB.Connection")
conn.Open("DSN=info")
var recordSet1 = Server.CreateObject("ADODB.Recordset");
var recordSet2 = Server.CreateObject("ADODB.Recordset");

recordSet1.Open("SELECT * from LocNotes"+" where Location ='" + moo + "'", conn);

 %>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body topmargin="0" bgcolor="#FFFFFF">
<center>
<img src="Images/banner.jpg">
</center>
<br>
</div>

<div class="InfoMainDIV" align="center">
<h1><%=moo%></h1>
<div id="choice">
<table border="1" width="100%" bgcolor="#CCCCCC" bordercolor="#000000" cellpadding="3" cellspacing="3"> 
 <tr>

<th bgcolor="#666666"><font color="#FFFFFF">Copier </font></th>
<th bgcolor="#666666"><font color="#FFFFFF">Wireless </font></th>
<th bgcolor="#666666"><font color="#FFFFFF">Phone Numbers</font></th>
<th bgcolor="#666666"><font color="#FFFFFF">Machines</font></th>
<th bgcolor="#666666"><font color="#FFFFFF">Users</font></th>
 </tr>

 <%
 while(!recordSet1.EOF)
 {
location = recordSet1("Location")
recordSet2.Open("SELECT * from Data"+" where Location ='" + location + "'", conn);
 Response.Write(recordset2("FirstName"));
 Response.Write("<tr>")
 Response.Write("<td bgcolor='#000066'><font color='#FFFFFF'>" + recordSet1("Copier") + "</font></td>");
 Response.Write("<td bgcolor='#000066'><font color='#FFFFFF'>" + recordSet1("Wireless") + "</font></td>");
 Response.Write("<td bgcolor='#000066'><font color='#FFFFFF'>" + recordSet1("PhoneNumbers") + "</font></td>");
 Response.Write("<td bgcolor='#000066'><font color='#FFFFFF'>" + recordSet1("Machines") + "</font></td>");
 Response.Write("<td bgcolor='#000066'><font color='#FFFFFF'>" + recordSet2("Device") + "</font></td>");

 Response.Write("</tr>");
 Response.Write("ddddd")
 Response.Write(location + "= location")
recordSet2.Close();
recordSet1.MoveNext();
}

%>

			</script>
</table>	
</div>	
</body>
</html>

Thanks For all help :)
 
Use a different SQL statement
Code:
Dim strSQL
strSQL = "SELECT N.*, T.TypeName FROM LocNotes N INNER JOIN NoteTypes T on N.NoteType = T.NoteType WHERE N.Location ='" & moo & "'"
recordSet1.Open(strSQL, conn);


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top