| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
please help me to get the data from the database
hi
i am trying to get the data from the access database in the web page. i got success to get the record for the for the first page now i am trying to link that records with another table to get the relevant record. i have two different tables in my database, one is manufacturer which has two datafields one is manufacturer_id and manufacturer_name and the second is models which has near about 10 fields. but both tables has same data in manufacuture_id and maker_id fields i want to relate these two fields to get result on second page. i am sending the code for both pages please help me to fix the problem. my first files code is <html> <head> <tittle><center> <body topmargin="0" > <table > <tr> <td width="740" align="left" valign="top" height="158"> <img border="0" src="images/banner.gif"></td> </tr> </table> <table> <tr> <td width="235" height="94"> <img border="0" src="images/images/contact_01.gif" width="235" height="94"></td> <td width="505" height="94"> <img border="0" src="images/images/contact_02.gif" width="505" height="94"></td> </tr> <tr> <td colspan="2" align="left" valign="top"> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="740" id="AutoNumber3"> <tr> <td width="254" background="images/4.gif" align="left" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="200" id="AutoNumber4"> <tr> <td width="25"> </td> <td width="175"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5"> <tr> <td width="100%" bgColor="#777777"><span class="white"> </span></td> </tr> <tr> <td bgColor="#a7a7a7"> <table cellSpacing="0" cellPadding="10" border="0"> <tr> <td width="165" bgColor="#ffffff"><center><b>Telephone</b><br> <font color="#727272" size="4"><b>519 739 0037</b></font><br> <b>Email.</b> </center></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> <td width="486" background="images/5.gif" align="center"> <%@ LANGUAGE="VBScript" %> <% Dim cnnSimple Dim rstSimple Dim strDBPath Dim iCounter Dim sRowColor strDBPath = Server.MapPath("fpdb/truck.mdb") Set cnnSimple = Server.CreateObject("ADODB.Connection") Set cnnSimple = Server.CreateObject("ADODB.Connection") cnnSimple.Open("DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=" & Server.MapPath("fpdb/truck.mdb")) Set rstSimple = cnnSimple.Execute("SELECT * FROM manufacturer") %> <table width="400" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse" bordercolor="#111111"> <tr> <td height="30"> </td> <td height="30"> </td> </tr> <% iCounter = 0 Do While Not rstSimple.EOF iCounter = iCounter + 1 If iCounter > 500 Then Response.Write "Too Many Records to display. Greater Than 500 Records in Table." Exit Do End If If sRowColor = " class=DB2ASPlight" Then sRowColor = " class=DB2ASPdark" Else sRowColor = " class=DB2ASPlight" End If %> <tr> <td <%=sRowColor%> height="20"> <a href="truckinfo.asp?manufacturer_id=<%= rstSimple.Fields("manufacturer_id").Value%>"> <%= rstSimple.Fields("manufacturer_id").Value %></a></td> <td <%=sRowColor%> height="20"><%= rstSimple.Fields("manufacturer_name").Value %></td> </tr> <% rstSimple.MoveNext Loop %> </table> <% cnnSimple.Close %> </td> </tr> </table> <img border="0" src="images/footer.gif"> </div> </td> </tr> </table> </div> </td> </tr> </table> </center> </body> </center> </html> ----------------------------------------------------------------------------------------------------------------------------------------- and my second file is <html> <head> <tittle><center> <body topmargin="0" > <table > <tr> <td width="740" align="left" valign="top" height="158"> <img border="0" src="images/banner.gif"></td> </tr> </table> <table> <tr> <td width="235" height="94"> <img border="0" src="images/images/contact_01.gif" width="235" height="94"></td> <td width="505" height="94"> <img border="0" src="images/images/contact_02.gif" width="505" height="94"></td> </tr> <tr> <td colspan="2" align="left" valign="top"> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="740" id="AutoNumber3"> <tr> <td width="254" background="images/4.gif" align="left" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="200" id="AutoNumber4"> <tr> <td width="25"> </td> <td width="175"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5"> <tr> <td width="100%" bgColor="#777777"><span class="white"> </span></td> </tr> <tr> <td bgColor="#a7a7a7"> <table cellSpacing="0" cellPadding="10" border="0"> <tr> <td width="165" bgColor="#ffffff"><center><b>Telephone</b><br> <font color="#727272" size="4"><b>519 739 0037</b></font><br> <b>Email.</b> </center></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> <td width="486" background="images/5.gif" align="center"> <%@ LANGUAGE="VBScript" %> <% Dim cnnSimple Dim rstSimple Dim strDBPath Dim iCounter Dim sRowColor Dim SQLStmt strDBPath = Server.MapPath("fpdb/truck.mdb") manufacturer_id=Request.QueryString("manufacturer_id") Set cnnSimple = Server.CreateObject("ADODB.Connection") Set cnnSimple = Server.CreateObject("ADODB.Connection") cnnSimple.Open("DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=" & Server.MapPath("fpdb/truck.mdb")) Set rstSimple = cnnSimple.Execute("select * from models where maker_id=manufacturer_id") %> <table width="400" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse" bordercolor="#111111" > <tr> <td height="30"> </td> <td height="30"> </td> </tr> <% iCounter = 0 Do While Not rstSimple.EOF iCounter = iCounter + 1 If iCounter > 500 Then Response.Write "Too Many Records to display. Greater Than 500 Records in Table." Exit Do End If If sRowColor = " class=DB2ASPlight" Then sRowColor = " class=DB2ASPdark" Else sRowColor = " class=DB2ASPlight" End If %> <tr> <td <%=sRowColor%> height="20"><%= rstSimple.Fields("model_id").Value %></td> <td <%=sRowColor%> height="20"><%= rstSimple.Fields("maker_id").Value %></td> <td <%=sRowColor%> height="20"><%= rstSimple.Fields("model").Value %></td> </tr> <% rstSimple.MoveNext Loop %> </table> <% rstSimple.Close Set rstSimple = Nothing cnnSimple.Close Set cnnSimple = Nothing %> </td> </tr> </table> <img border="0" src="images/footer.gif"> </td> </tr> </table> </div> </td> </tr> </table> </center> </body> </center> </html> |
|
#2
|
|||
|
|||
|
Answer
Set rstSimple = cnnSimple.Execute("select * from models where maker_id=" & Request.querystring("manufacturer_id") & """)"
maker_id is short for manufacturer id correct! Bob@lyrex.com Last edited by spungebob : April 5th, 2004 at 12:14 PM. Reason: mistake made |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > please help me to get the data from the database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|