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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Invalid Null error

Status
Not open for further replies.

axslearnr

Technical User
Apr 1, 2004
78
US
Create an ADO Connection to connect to the sample database.
Hi
I am getting Invalid null error. Ihave many records in my table but still when i say drst.MoveLast i get this error. Pls let me know.


set dconn = Server.CreateObject("ADODB.Connection")
dconn.open "DSN=Metrics;uid=" & session("Userid") & ";pwd=" & session("Password")
Set drst=Server.CreateObject("adodb.recordset")
dstrSQL="SELECT employee_training.Training_Date FROM employee_training ORDER by [Training_Date] Desc;"
drst.open dstrSQL, dconn, 2

'drst.MoveFirst
if len(StartDate) > 2 then

'Get date values entered in fields
StartDate = DateValue(StartDate)
EndDate = DateValue(request("EndDateMonth") & "/" & request("EndDateDay") & "/" & request("EndDateYear"))

'Set date values that are displayed on form
EDate = EndDate
BDate = StartDate
FirstTime = False

else
FirstTime = True
EDate = DateValue(drst("Training_Date"))
drst.movelast
BDate = DateValue(drst("Training_Date"))


end if

drst.close
set drst = nothing
 
in your select ...do where

employee_training.Training_Date is not null or
> 0 as it a date.....

 
One small problem: you may omit records that you actually want.

You could also test for a null value in the recordset before you assign it to the variable.

Code:
if not isnull(drst("Training_Date")) then
    BDate = DateValue(drst("Training_Date"))
else
    BDate = dteDefaultDate
end if

...also consider testing for EOF (end of file) before using the recordset.

Code:
if not drst.EOF then
    [i]your code[/i]
else
    strError = "There was an error processing your request"
end if

Hope this helps!

gtg.jpg

GTG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top