| Author |
Topic Search Topic Options
|
felix.akinyemi
Groupie
Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
|
Post Options
Thanks(0)
Quote Reply
Topic: Help With Code Posted: 07 January 2005 at 12:56pm |
Can someone please tell me if there is anything wrong with this code
UserID = Request.Form("ID") (lets say its equal to 5)
dbfile = Server.MapPath("db.mdb") Set OBJdbConnection = Server.CreateObject("ADODB.Connection") OBJdbConnection.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & dbfile
Set rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM tblUsers WHERE User_ID ='" & UserID & "'" rs.Open sql, OBJdbConnection, 3, 3
If Not rs.EOF Then PageTitle = rs.fields("field1") PageCode = rs.fields("field2") PagePassword = rs.fields("field2") End If
|
The problem is that its not getting the values from the database tables...
PageTitle, PageCode and PagePassword are returning nothing
am i doing something wrong...
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 1:20pm |
|
not sure 100% why its not working
but this dbfile = Server.MapPath("db.mdb")
should be
dbfile = "Server.MapPath("db.mdb") "
also can someone tell me what the 3,3 does, i don't use them i ussually have rs.open strSQL, strCon
what does the ,3,3 do?
also might be best to use SELECT tblUsers.*.
defines the query better.
not usre if its ment to be but you have the PagePassword and PageCode the same value.
NOTE:
its best to havge
if rs.EOF then
Else
END IF
or the other way round, prevents an error , when a record isn't found.
|
 |
meteor
Groupie
Joined: 31 August 2003
Location: Iran
Status: Offline
Points: 67
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 3:05pm |
dbfile = Server.MapPath("db.mdb")
it is Correct
try Diffrent Driver Like Jet Engine
is Your Field Names True ? Change
If Not rs.EOF Then PageTitle = rs.fields("field1") PageCode = rs.fields("field2") PagePassword = rs.fields("field2") End If
to
Do While Not rs.Eof
...
rs.moveNext
Loop
There is No need to use 3,3 Remove Them For more Information About ADO Constant Open file ADOVBS.INC
At Last Write Your Error Here.. Realty Error- try to remove Check mark Of Friendly Error Message at Your IE (Internet Option-> Advanced)
|
|
|
 |
felix.akinyemi
Groupie
Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 3:22pm |
Ok, the error im getting is...
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
|
The code on the error line is
rs.Open sql, OBJdbConnection
|
i tried it with the do while loop, same error...
with or with the 3,3 still the same thing... and Friendly Error is of!!!
|
 |
felix.akinyemi
Groupie
Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 3:26pm |
I tried these and both giving the same errors
sql = "SELECT * FROM tblUsers WHERE User_ID ='" & UserID & "'"
|
sql = "SELECT tblUsers.User_ID FROM tblUsers WHERE tblUsers.User_ID ='" & UserID & "'"
|
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 3:33pm |
the error is on that line because that the line the SQL is ececuted.
by any change the UserID isn't a number
if so you can take the ' ' from the query so use the below
sql = "SELECT tblUsers.User_ID FROM tblUsers WHERE tblUsers.User_ID = " & UserID
|
|
 |
felix.akinyemi
Groupie
Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 3:51pm |
ok, thanks, that worked... but still another error
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
|
and the code on the line is
PageTitle = rs.fields("field1")
|
|
 |
felix.akinyemi
Groupie
Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 January 2005 at 3:54pm |
and
PageTitle = rs.fields("field1")
it has text not numbers...
|
 |