Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a date out of Access 1

Status
Not open for further replies.

mbutler55

Instructor
Feb 5, 2003
33
US
I have a table called CurrentDateAndTime. It consists of 1 field and 1 record. The field is called CurDateTime. It has an automatically filled in value from the function Now(). My db will be static not dynamic and this field will store when the db was last updated.

In my web page I have:
set objRS = Server.CreateObject ("ADODB.Recordset")
sql="SELECT CurDateTime FROM CurrentDateAndTime"
objRS.CursorLocation = adUseClient
objRS.Open sql, objConn, 3
objRS.MoveFirst
response.write objRS("CurDateTime")
objRS.close

This gives an error that says:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

I know the record is in the db and the field is populated. What am I doing wrong!?
 
>> sql="SELECT CurDateTime FROM CurrentDateAndTime"

could be there or...

>> objRS.Open sql, objConn, 3

there since u didn't show that.
 
I don't understand what you are saying since both of those lines are included in my page.
 
the value of 'objConn' is not visible in your post since you did not include the code that initialized the variable.
 
Pardon me - here is the complete code:

Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DRIVER={Microsoft Access
Driver (*.mdb)};" & "DBQ=" & Server.MapPath
("fpdb/CryoCathIPR.mdb") & ";"
objConn.Open
set objRS = Server.CreateObject ("ADODB.Recordset")
sql="SELECT CurDateTime FROM CurrentDateAndTime"
objRS.CursorLocation = adUseClient
objRS.Open sql, objConn, 3
objRS.MoveFirst
response.write objRS("CurDateTime")
objRS.close
 
>> objConn.ConnectionString = "DRIVER={Microsoft Access
>> Driver (*.mdb)};" & "DBQ=" & Server.MapPath
>> ("fpdb/CryoCathIPR.mdb") & ";"

that would be the first thing i would analyze... something like:

<!--
<%=Server.MapPath &quot;fpdb/CryoCathIPR.mdb&quot;%>
-->

keep in mind i don't know VBScript well ( er.. read barely)

-pete
 
Why not use the following to get the lastupdated date/time for your access database. This way, you don't have to make another database call to get the necessary information.

you can make use of the FileSystemObject to handle this.

dim fs, f
set fs=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
set f=fs.GetFile(Server.MapPath(&quot;/sandbox/yourdatabase.mdb&quot;))

Response.Write(&quot;The database was last modified on: &quot; & f.DateLastModified)
set f=nothing
set fs=nothing
regards,
Brian
AOL IM: FreelanceGaines

AG00280_.gif
 
No problem, glad to have helped.
regards,
Brian

AOL IM: FreelanceGaines

Get the Best Answers! FAQ333-2924
Is this an asp FAQ? FAQ333-3048
Tek-Tips Best Practices: FAQ183-3179

AG00280_.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top