Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2007, 08:50 AM
Authorized User
 
Join Date: Jan 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default SELECT * FROM help

 Hi everyone,
I am new to this group so if I have missed the answer to this question I am sorry.

I have a login page using an access database to verify username.

when I use the like statement it returns the correct data but I need it to =the username in the table.

this is the code:

qry = "SELECT * FROM userlist WHERE username = '" & Request.Form("txtUserName") & "%'"


Set oRS = oConn.Execute(qry)

if not oRS.EOF then
while not oRS.EOF
response.write ("Welcome. "& oRs.Fields(username) & " <br>")

oRS.movenext
wend
else response.Write("Username not found.")
oRS.close
end if

Can someone help me with this please?
Thanks,
Dink
 
Old January 16th, 2007, 08:53 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What happens if you execute that query inside your database? Does it return the correct data?

Also this:
oRs.Fields(username)

should be
oRs.Fields("username")



-----------------------------------------------------------
I will only tell you how to do it, not do it for you.------------
Unless, of course, you want to hire me to do work for you.---
^^Thats my signature--------------------------------------
-----------------------------------------------------------
http://www.catb.org/~esr/faqs/smart-questions.html -------
^^Took that from planoie's profile--------------------------
-----------------------------------------------------------
 
Old January 16th, 2007, 11:55 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This line is suspect:

qry = "SELECT * FROM userlist WHERE username = '" & Request.Form("txtUserName") & "%'"

Are you expecting a percentage sign at the end of your entries in the username field?


Woody Z
http://www.learntoprogramnow.com
 
Old January 16th, 2007, 08:37 PM
Authorized User
 
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

From a SQL perspective, the % sign works as a wild card with the LIKE but shouldn't be used to test whether the username matches exactly. You might consider pushing both sides of the comparison to UPPER to get past case-sensitivity issues in your test too.


 
Old January 16th, 2007, 11:50 PM
Authorized User
 
Join Date: Jan 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you all for your help. Removing the % did the trick.
The login needs to check for case sensitive.
You are wonderful!
dink





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
select="node1", select="node2"... Baldo XSLT 7 March 12th, 2004 10:38 AM
Select Within A Select Problem vinyl-junkie Classic ASP Databases 6 June 7th, 2003 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.