Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help With Code
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help With Code

 Post Reply Post Reply Page  123>
Author
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post 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...

Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
meteor View Drop Down
Groupie
Groupie
Avatar

Joined: 31 August 2003
Location: Iran
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote meteor Quote  Post ReplyReply Direct Link To This Post 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)

Sincerely
--------------------
PowerFull Scripts For NTTacPlus
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post 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!!!
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post 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 & "'"
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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 Tongue

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

Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post 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")
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post Posted: 07 January 2005 at 3:54pm
and
 
PageTitle = rs.fields("field1")
 
it has text not numbers...
Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.