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

Display Correct value

Status
Not open for further replies.

Dashsa

Programmer
Aug 7, 2006
110
US
Hello,
I have a table that has a field set that is a look-up to another table.
The problem is i want to display the data in a table but its only displayiny the value of the look up table and not the name .
How do I display the name?
Below is the code
Code:
<html>
<head>
<title>Documents that have Errors</title>


<script language="javascript">
<!-- Hide Script from old browsers

function goTo(newLoc)
	{
		var newPage = newLoc.options[newLoc.selectedIndex].value;
		if(newPage != "")
		{
		window.location.href = newPage;
		}
	}

// End Hiding    -->
</script>


<%@ language="JScript"%>
	<!--   Hide from older Browsers
	<%
	
	
var conn = Server.CreateObject("ADODB.Connection");
	var recordSet1 = Server.CreateObject("ADODB.RecordSet");

	conn.Open("DSN=POnum");
	recordSet1.Open("select * from Images where Status = 3",conn,1,3);
	%>	
	//  End Hiding   -->
	
	
</head>
<body>
<img src="Banner.jpg"><br>

	<form name="Choice">
	<select name="status" onChange="goTo(this)">
	<option value="" selected="selected">Please Choose A Status</option>
	<option value="unread.asp">Unread</option>
	<option value="read.asp">Read</option>
	<option value="error.asp">Error</option>
	<option value="rescan.asp">Rescan</option>
	</select>
	</form>
	<h1>ERROR</h1>
	
	<table border="1" width="100%">
	<tr>	
	<th>ID</th> 
	<th>Image Source </th>
	<th>P O Number</th>
	<th>Status</th>
	<th>Document Type </th>
	<th>Job Name</th>
	<th>Company</th>
	<th>Flagged ?</th>
	<th>Reason</th>
	</tr>
	
<%
while(!recordSet1.EOF)
	{
	Response.Write("<tr>")
	Response.Write("<td>"+ recordSet1("ID") + "</td>");
	Response.Write("<td>"+ recordSet1("ImgSrc") + "</td>");
	Response.Write("<td>"+ recordSet1("PONumber") + "</td>");
	Response.Write("<td>"+ recordSet1("Status") + "</td>");
	Response.Write("<td>"+ recordSet1("DocType") + "</td>");
	Response.Write("<td>"+ recordSet1("JobName") + "</td>");
	Response.Write("<td>"+ recordSet1("Company") + "</td>");
	Response.Write("<td>"+ recordSet1("Flagged") + "</td>");
	Response.Write("<td>"+ recordSet1("Reason") + "</td>");
	Response.Write("</tr>")
recordSet1.MoveNext();
	}

%> 
</table>
</body>
</html>
 
You have to JOIN the 2 tables in your SELECT instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks
I tried to do a join
Code:
recordSet.Open("select * from Images,Company" +" where Company =" + comN + "",conn,1,3);

But i get an error
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Company =Bay 10 Ventures'.
Any more Ideas?

Thanks Again

 
I thought of something like this:
recordSet.Open("SELECT yourFieldListHere FROM Images INNER JOIN Company ON Images.CompanyForeignKey=Company.CompanyPrimaryKey",conn,1,3);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top