SQL til flere tabeller - finder ingen data
Hey!1 access Database med følgende tabeller
Billeder
********
id_nr - Autonummerering
ID
Sti
Tekst
Kommentar
*********
id_n - Autonummerering
k_id
Navn
Kommentar
Dato
Tid
Rapporter
*********
Id_no - Autonummerering
Brugernavn
Forfatter
osv....
Det virker delvist, men den finder ikke de data der er i kommentar hvor kommentar.k_id = rapporter.id_no
og det er et problem. Nogen der kan se problemet ?
<% Session.LCID=1030 %>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query for the database
Dim strsql2
Dim lngRecordNo 'Holds the record number to be updated
'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString("ID"))
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/fangster.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM (rapporter LEFT OUTER JOIN billeder ON rapporter.id_no = billeder.id) LEFT OUTER JOIN kommentar ON kommentar.k_id = billeder.id WHERE ID_no=" & lngRecordNo & " ORDER BY id_nr;"
'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
%>
<html>
<head>
<title>View_selected</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Pragma" content="no-cache">
</head>
<body bgcolor="#232323" text="black">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2">
<tr>
<td width="100%" class=head align=center>
<% = rsGuestbook("forfatter") %>'s fangstrapport
</td>
</tr>
<tr>
<td width="100%">
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2">
<tr>
<td width="100%" align=left class=text1>
<a href="view_select_bg.asp">
Tilbage
</a>
</td>
</tr>
</table>
</center>
</div>
<br>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-width:0px; border-collapse: collapse" width="530" id="table2" bordercolor="#000000">
<tr>
<td colspan="4" align=center class="head" ><b><% = rsGuestbook("overskrift") %></b></td>
</tr>
<tr>
<td colspan="4" align=center class="head"> </td>
</tr>
<tr>
<td class="text1" rowspan="9" width="20%" style="border-left: medium none #000000; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom: medium none #000000">
<%if len(rsGuestbook("url"))>0 then
maksbredde = 150
makshojde = 180
Set objImg = Server.CreateObject("ImgSize.Check")
objImg.FileName = server.mappath(rsGuestbook("url"))
if objImg.Height > makshojde then
ratio = objImg.Height / makshojde
newheight = objImg.Height /ratio
newwidth = objImg.Width /ratio
if newwidth > maksbredde then
ratio = newwidth / maksbredde
newheight = newheight /ratio
newwidth = newwidth /ratio
end if
elseif objImg.Width > maksbredde then
ratio = objImg.Width / maksbredde
newheight = objImg.Height /ratio
newwidth = objImg.Width /ratio
if newheight > makshojde then
ratio = newheight / makshojde
newheight = newheight /ratio
newwidth = newwidth /ratio
end if
else
newheight = objImg.Height
newwidth = objImg.Width
end if
%>
<a href="<%= rsguestbook("url")%>" target=_blank>
<img src="<%= rsguestbook("url")%>" border="0" height="<%= newheight %>" width="<%= newwidth %>" align="top"></a>
<% else %>
<img src="../images/nopix.gif" border="0" align="top">
<%end if%>
</td>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Indsendt af</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("forfatter") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium"> </td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">Dato for fangst</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("fangstmnd") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium"> </td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">Fangst</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("fangst") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium"> </td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">Agn</td>
<td class="text1" style="border-style: none; border-width: medium" >
:<% = rsGuestbook("agn") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Vægt i kg</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("vaegt") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Kategori</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("metode") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Sted</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("sted") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Oprettet d.</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("dato") %></td>
</tr>
<tr>
<td class="text1" width="4%" style="border-style: none; border-width: medium">
</td>
<td class="text1" width="30%" style="border-style: none; border-width: medium">
Klokken</td>
<td class="text1" style="border-style: none; border-width: medium" >
: <% = rsGuestbook("tid") %></td>
</tr>
</table>
</div>
<br>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-bottom-width:0px" width="530" id="table2" bordercolor="#000000">
<tr>
</tr>
<tr>
<td class="text1" colspan="3" style="border-left-color: #000000; border-left-width: 1px; border-right-color: #000000; border-right-width: 1px; border-top-style: none; border-top-width: medium"><%=rsguestbook("beretning")%>
<br><br>
</td>
</tr>
</table>
</div>
<br>
<% if rsguestbook("brugernavn") = session("userid") then%>
<div align="center">
<table border='0' cellpadding='0' cellspacing='0' style='border-width:0px; border-collapse: collapse' width='530' id='table2' bordercolor='#000000'> <tr>
<td class=text1 align=center>
<a href='xtra/indtast_billede_tekst.asp?id=<%=lngRecordNo%>'>Upload flere billeder</a>
</td>
</tr>
</table>
<% End if %>
<br>
<div align="center">
<table border='0' cellpadding='0' cellspacing='0' style='border-width:0px; border-collapse: collapse' width='530' id='table2' bordercolor='#000000'> <tr>
<td class=head align=center>
<%
if rsguestbook("id") <> "" then
response.write "<b>Ekstra billeder</b><br><br>"
dim i
i = 0
%>
</td>
</tr>
</table>
<br>
<table border='0' cellpadding='0' cellspacing='4' style='border-width:0px; border-collapse: collapse' width='530' id='table2' bordercolor='#000000'>
<tr>
<%
'Loop through the recordset
Do While not rsGuestbook.EOF
%>
<td class=text1>
<a href="<%= rsguestbook("sti")%>" target=_blank>
<img src="<%= rsguestbook("sti")%>" border="0" height="<%= newheight %>" width="<%= newwidth %>" align="top">
</a>
<%= rsguestbook("tekst")%>
</td>
<%
If i = 3 then
response.write "</tr>"
response.write "<tr>"
i = 0
Else
i= i + 1
End If
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop
'response.write "</tr>"
'else
'response.write "<b>ingen ekstra billeder</b><br><br>"
End if
%>
</table>
</div>
<%
'Loop through the recordset
Do While not rsGuestbook.EOF
%>
<%
Response.write ("Kommentar")
Response.write (rsguestbook("k_id"))
Response.write (rsguestbook("Navn"))
Response.write (rsguestbook("Kommentar"))
Response.write (rsguestbook("Dato"))
Response.write (rsguestbook("Tid"))
%>
<%
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop
%>
</body>
</html>
</font><%
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
