Can't tell much w/o code...
Printable View
Can't tell much w/o code...
This is what i'm using to set-up the connection and get the recordset :
<%
Set Con = Server.CreateObject ("ADODB.Connection")
Con.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=d:\InetPub\wwwroot\development\News.mdb"
set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open "SELECT Title, ID FROM NewsArticles WHERE ID > ((SELECT MAX(ID) from NewsArticles)-3) ORDER BY ID DESC", Con, 3, 3
%>
This is how the recordset is used :
<font face="Arial, Helvetica, sans-serif" size="2" color="#000000"><b>
<p><a href="newsarticle.asp?ID=<%=rs("ID")%>"><%=rs("Title")%></a></p>
<%rs.MoveNext%>
<p><a href="newsarticle.asp?ID=<%=rs("ID")%>"><%=rs("Title")%></a></p>
<%rs.MoveNext%>
<p><a href="newsarticle.asp?ID=<%=rs("ID")%>"><%=rs("Title")%></a></p>
</b>
</font>
I then close recordset and connection at the end of the page :
<%
rs.Close
Con.Close
%>
Ok i think i found the problem, there was a problem with the database that was causing only 2 records to be retreived and not 3 like the page was expecting, this was causing the page to error and not get to the end and hence not close the database connection etc.
Thats what i THINK was going on anyway ...
For starters, why are you using the ODBC driver for Access instead of the OLEDB provider?
Also your ORDER BY clause needs a comma to deparate ID and DESC.Code:Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\InetPub\wwwroot\development\News.mdb;Persist Security Info=False"
'Loop through the recordset:
<font face="Arial, Helvetica, sans-serif" size="2" color="#000000"><b>
<%Do until rs.EOF%>
<p><a href="newsarticle.asp?ID=<%=rs.Fields("ID")%>"><%=rs.Fields("Title")%></a></p>
<%rs.MoveNext
Loop%>
</b></font>
Thanks for the info, looping through the recordset is a good idea and would have actually solved my problem, i really have no excuse for not thinking of it in the first place ! :)
One thing i don't get though ... can you explain what the difference is between my connection string and the one you suggested as what I am using IS working, would the be a benefit to doing it your way?
Best Regards
Ian.
ODBC is slower than OLEDB.
In fact, I can't think of ANY reason to use the Access ODBC driver... not even sure why they supply one for windows based platforms...