
Originally Posted by
chewystuey
hey peeps
im teaching myself VB.net and have come accross a small prob -
i have created a login page which accesses data from and MS Access db table.
The login works fine
however i am trying to place the clientid into a session variable and am getting the above error. Data does exist in the table and it is retrieving it. here is the code - hope u can help
objcmd= New oledbcommand("Select * from ClientTable " & _
"where username='" & strUsername & _
"' AND Password='" & strPassword & "'", objconn)
objconn.open()
objDR = objcmd.executereader()
if objDR.HasRows then
session("currentlog")=objdr("clientid")
end if
objDR.close()
somebody please enlighten me
i have also tried
session("currentlog")=objdr.item("clientid") and
session("currentlog")=objdr(0)
thanks in advance
stu
Remeber the If objDR.read() Then ... Like below
Code:
objconn.open()
objDR = objcmd.executereader()
if objDR.read() then
session("currentlog")=objdr("clientid")
end if
objDR.close()
objDR.HasRows does not take you to the first record in the datareader, but objDR.read() does.