|
-
Nov 6th, 2000, 11:56 PM
#1
Thread Starter
Frenzied Member
Can't tell much w/o code...
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Nov 7th, 2000, 04:44 AM
#2
Member
Here is the 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
%>
-
Nov 7th, 2000, 09:05 AM
#3
Member
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 ...
-
Nov 7th, 2000, 11:15 AM
#4
Thread Starter
Frenzied Member
For starters, why are you using the ODBC driver for Access instead of the OLEDB provider?
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>
Also your ORDER BY clause needs a comma to deparate ID and DESC.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Nov 7th, 2000, 11:23 AM
#5
Member
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.
-
Nov 7th, 2000, 09:17 PM
#6
Thread Starter
Frenzied Member
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...
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|