teyeheimans
11-06-2002, 04:18 PM
aargh, please help me.
This is the situation:
Ive got an Access database with 2 tables:
adressenlijst
id
adres
postcode
plaats
telefoon
namenlijst
naam
leeftijd
adres_id
namenlijst.adres_id contains the id to adressenlijst.id.
Ive got a script with list the addresses and shows the linked people with it. Only when the address has no people linked to it, the address isn't showed.
I know that i can fix that problem with a Join and instead to use a inner join, to use a Left Join. This wont work eather...
Whats wrong???
Here's my script:
<%
'maak database connectie object
Set DB_CONN = Server.CreateObject("ADODB.Connection")
DB_CONN.Open "FILEDSN=" & server.mappath("schoolApp.dsn")
Dim PageLength, NumPages, CurrentPage, Address, ShowTel
'aantl records per pagina
PageLength = 20
'Telefoonnummer laten zien of niet
ShowTel = True
If Request.QueryString("max") = "" Then
PageLength = 20
Else
PageLength = CInt(Request.QueryString("max"))
End If
'maak recordset object
Set RS = Server.CreateObject("ADODB.Recordset")
RS.PageSize = PageLength
RS.CacheSize = PageLength
'De query
'SQL_STRING = "SELECT * FROM adressenlijst LEFT JOIN namenlijst ON namenlijst.adres_id = adressenlijst.id ORDER BY adressenlijst.id"
SQL_STRING = "SELECT * FROM namenlijst RIGHT JOIN adressenlijst ON namenlijst.adres_id = adressenlijst.id" 'WHERE achternaam Like '" & Char & "%' ORDER BY achternaam"
'^ i tried a lot of these, but it seems to make no difference
'voer de query uit
RS.Open SQL_STRING, DB_CONN, adOpenStatic, adLockReadOnly, adCmdText
'paginanummer via url
If Request.QueryString("page") = "" Then
CurrentPage = 1
Else
CurrentPage = CInt(Request.QueryString("page"))
End If
NumPages = RS.PageCount
If CurrentPage > NumPages Then
CurrentPAge = NumPages
End If
If CurrentPage < 1 Then
CurrentPage = 1
End If
If NumPages = 0 Then
Response.Write("Geen records aanwezig!")
Else
RS.AbsolutePage = CurrentPage
%>
<body onLoad='document.main.max.value=<%=PageLength%>'>
<form name='main'>
<table width='100%' border=1 cellspacing=0>
<tr bgcolor=eeeee>
<td valign=top>
<table width=100% cellspacing=0 cellpadding=0 border=0>
<tr >
<td valign=top>
<b>Pagina:</b>
<% If CurrentPage > 1 Then %>
<a href='index.asp?pg=overzicht&page=<%=CurrentPage - 1%>&max=<%=PageLength%>' style='text-decoration: none;'>[ < ]</a>
<% End If
For i = 1 To NumPages
%> <a href='index.asp?pg=overzicht&page=<%=i%>&max=<%=PageLength%>' style='text-decoration: none;'>[ <%
If i = CurrentPage Then
Response.Write("<b>" & i & "</b>")
Else
Response.Write(i)
End If
%> ]</a>
<%
Next
If CurrentPage < NumPages Then
%><a href='index.asp?pg=overzicht&page=<%=CurrentPage + 1%>&max=<%=PageLength%>' style='text-decoration: none;'>[ > ]</a>
<%
End If
%>
</td>
<td align=right nowrap valign=top>
Aantal <i>leerlingen</i> per pagina:
<select name=max onChange="window.location.href='index.asp?pg=overzicht&page=1&max='+this.value">
<option value=5>5</option>
<option value=20>20</option>
<option value=50>50</option>
<option value=100>100</option>
<option value=250>250</option>
</select>
</td>
</tr>
</table>
</td>
</tR>
</form>
<%
RecordCount = 0
Do While RecordCount < PageLength And Not RS.eof
If Address <> RS("adres_id") Then
If Address <> "" Then %>
</table>
</td>
</tr>
</table>
</span>
</td>
</tr>
<%
End If
%>
<!-- show the records here, 2 much html -->
<%
Address = RS("adres_id")
End If
%>
<tr>
<td><%=RS("achternaam") & ", " & RS("voornaam") & " " & RS("tussenvoegsel")%></td>
<td><%=RS("geslacht")%></td>
<td><%=RS("klas_leraarcode")%></td>
</tr><%
RecordCount = RecordCount + 1
RS.MoveNext
Loop %>
</table>
</td>
</tr>
</table>
</span>
</td>
</tr>
</table>
<%
End If
RS.Close
Set RS = Nothing
DB_CONN.Close
Set DB_CONN = Nothing
%>
plz help :(
This is the situation:
Ive got an Access database with 2 tables:
adressenlijst
id
adres
postcode
plaats
telefoon
namenlijst
naam
leeftijd
adres_id
namenlijst.adres_id contains the id to adressenlijst.id.
Ive got a script with list the addresses and shows the linked people with it. Only when the address has no people linked to it, the address isn't showed.
I know that i can fix that problem with a Join and instead to use a inner join, to use a Left Join. This wont work eather...
Whats wrong???
Here's my script:
<%
'maak database connectie object
Set DB_CONN = Server.CreateObject("ADODB.Connection")
DB_CONN.Open "FILEDSN=" & server.mappath("schoolApp.dsn")
Dim PageLength, NumPages, CurrentPage, Address, ShowTel
'aantl records per pagina
PageLength = 20
'Telefoonnummer laten zien of niet
ShowTel = True
If Request.QueryString("max") = "" Then
PageLength = 20
Else
PageLength = CInt(Request.QueryString("max"))
End If
'maak recordset object
Set RS = Server.CreateObject("ADODB.Recordset")
RS.PageSize = PageLength
RS.CacheSize = PageLength
'De query
'SQL_STRING = "SELECT * FROM adressenlijst LEFT JOIN namenlijst ON namenlijst.adres_id = adressenlijst.id ORDER BY adressenlijst.id"
SQL_STRING = "SELECT * FROM namenlijst RIGHT JOIN adressenlijst ON namenlijst.adres_id = adressenlijst.id" 'WHERE achternaam Like '" & Char & "%' ORDER BY achternaam"
'^ i tried a lot of these, but it seems to make no difference
'voer de query uit
RS.Open SQL_STRING, DB_CONN, adOpenStatic, adLockReadOnly, adCmdText
'paginanummer via url
If Request.QueryString("page") = "" Then
CurrentPage = 1
Else
CurrentPage = CInt(Request.QueryString("page"))
End If
NumPages = RS.PageCount
If CurrentPage > NumPages Then
CurrentPAge = NumPages
End If
If CurrentPage < 1 Then
CurrentPage = 1
End If
If NumPages = 0 Then
Response.Write("Geen records aanwezig!")
Else
RS.AbsolutePage = CurrentPage
%>
<body onLoad='document.main.max.value=<%=PageLength%>'>
<form name='main'>
<table width='100%' border=1 cellspacing=0>
<tr bgcolor=eeeee>
<td valign=top>
<table width=100% cellspacing=0 cellpadding=0 border=0>
<tr >
<td valign=top>
<b>Pagina:</b>
<% If CurrentPage > 1 Then %>
<a href='index.asp?pg=overzicht&page=<%=CurrentPage - 1%>&max=<%=PageLength%>' style='text-decoration: none;'>[ < ]</a>
<% End If
For i = 1 To NumPages
%> <a href='index.asp?pg=overzicht&page=<%=i%>&max=<%=PageLength%>' style='text-decoration: none;'>[ <%
If i = CurrentPage Then
Response.Write("<b>" & i & "</b>")
Else
Response.Write(i)
End If
%> ]</a>
<%
Next
If CurrentPage < NumPages Then
%><a href='index.asp?pg=overzicht&page=<%=CurrentPage + 1%>&max=<%=PageLength%>' style='text-decoration: none;'>[ > ]</a>
<%
End If
%>
</td>
<td align=right nowrap valign=top>
Aantal <i>leerlingen</i> per pagina:
<select name=max onChange="window.location.href='index.asp?pg=overzicht&page=1&max='+this.value">
<option value=5>5</option>
<option value=20>20</option>
<option value=50>50</option>
<option value=100>100</option>
<option value=250>250</option>
</select>
</td>
</tr>
</table>
</td>
</tR>
</form>
<%
RecordCount = 0
Do While RecordCount < PageLength And Not RS.eof
If Address <> RS("adres_id") Then
If Address <> "" Then %>
</table>
</td>
</tr>
</table>
</span>
</td>
</tr>
<%
End If
%>
<!-- show the records here, 2 much html -->
<%
Address = RS("adres_id")
End If
%>
<tr>
<td><%=RS("achternaam") & ", " & RS("voornaam") & " " & RS("tussenvoegsel")%></td>
<td><%=RS("geslacht")%></td>
<td><%=RS("klas_leraarcode")%></td>
</tr><%
RecordCount = RecordCount + 1
RS.MoveNext
Loop %>
</table>
</td>
</tr>
</table>
</span>
</td>
</tr>
</table>
<%
End If
RS.Close
Set RS = Nothing
DB_CONN.Close
Set DB_CONN = Nothing
%>
plz help :(