|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I have this code:
Code:
<%
'Dimension variables
'Holds the Database Connection Object
Dim adoCon
'Holds the recordset for the records in the database
Dim rsEvents
'Holds the SQL query to query the database
Dim strSQL
'Create an ADO connection object
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("oak.mdb")
'Create an ADO recordset object
Set rsEvents = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database with
strSQL = "SELECT * FROM events order by events.updated DESC LIMIT 0, 1 WHERE events.type = 'past';"
'Open the recordset with the SQL query
rsEvents.Open strSQL, adoCon
'Loop through the recordset
Do While not rsEvents.EOF
'Write the HTML to display the contents of the recordset
Response.Write (rsEvents("ID"))
Response.Write ("<br>")
Response.Write (rsEvents("type"))
Response.Write ("<br>")
Response.Write (rsEvents("body"))
Response.Write ("<br>")
Response.Write (rsEvents("updated"))
Response.Write ("<br>")
'Move to the next record in the recordset
rsEvents.MoveNext
Loop
'Reset server variables
rsEvents.Close
Set rsEvents = Nothing
Set adoCon = Nothing
%>
Quote:
Line 25 is the SQL query Code:
strSQL = "SELECT * FROM events order by events.updated DESC LIMIT 0, 1 WHERE events.type = 'past';" Please Help? - D# |
|
#2
|
|||
|
|||
|
I'm thinking the WHERE clause must be before the ORDER BY. I'm not exactly sure what LIMIT 0, 1 does, either, so I'm not sure where that goes.
Maybe something like: strSQL = "SELECT * FROM events WHERE events.type = 'past' ORDER BY events.updated DESC LIMIT 0, 1;" If that doesn't work, take out the LIMIT 0, 1 and play with it. |
|
#3
|
|||
|
|||
|
There is no LIMIT clause in Access, it's MySQL specific.
|
|
#4
|
||||
|
||||
|
whoops
|
|
#5
|
||||
|
||||
|
Sorry i'm used to MySQL!
Is there any LIMIT type statement is Access? - D# |
|
#6
|
||||
|
||||
|
You maybe having a problem with the amount of users connecting to your access database (access bogs down if more than 20 users are logged in)
|
|
#7
|
|||
|
|||
|
If I am understanding the LIMIT statement correctly (I don't know a thing about MySQL), what you would want is the following:
You want only 1 row returned for this query (given the 0, 1). You want to start with the first row and grab only 1. If this is correct, you'd want something like: strSQL = "SELECT TOP 1 * FROM events WHERE events.type = 'past' ORDER BY events.updated DESC;" IIRC, there's no way to say in Access to start at the 20th record and grab 10 of them. So if you wanted to do LIMIT 20, 10 I don't see how you could do that unless you did a TOP 30 and looped past the first 20 in a recordset. Not sure if that helps you or not. J |
|
#8
|
||||
|
||||
|
That helps
|
|
#9
|
||||
|
||||
|
Thx!
I won't be having more than 2 MAX at a time looking at the page! - D# |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Access DB Query Prob! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|