Print Page | Close Window

Case sensitive search in Access Database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2154
Printed Date: 29 March 2026 at 10:53am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Case sensitive search in Access Database
Posted By: vicky_c
Subject: Case sensitive search in Access Database
Date Posted: 26 April 2003 at 6:25am

Hiya!

I have a big problem.  On my site I have a member area ppl can join and log in to but recently I found out that if you join with say the name 'Michelle' and there is already a 'michelle' in the database it would allow that but when it is verifying a log in its not case sensitive anymore and so it just looks for the first michelle.

How do I change it so that its not case sensitive?  So that it woudln't allow a michelle and a Michelle?

Here is the part of the script that creates a new user:

________________________________________________________


  'Build connection
 set conn = server.CreateObject ("ADODB.Connection")
 conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\home\Default\**********************"
 set rs = server.CreateObject ("ADODB.Recordset")
 'Open all records
 rs.Open "SELECT * FROM admin", conn, 3, 3
   
 'Check if username doesn't already exist
 do while not rs.EOF
  if rs("username")=username then
   set rs=nothing
   set conn=nothing
   Response.Redirect("taken.asp")
  end if
  rs.MoveNext
 loop

_________________________________________________________

Please help me! 
Thanks so much for reading

Loadsa love,
Vicky xxx




Replies:
Posted By: ultramods
Date Posted: 26 April 2003 at 6:33am

You could only allow users to have lower case usernames.

For example

username="ULTRAMODS"

RESPONSE.WRITE(LCase(username))

would change username to ultramods



Posted By: vicky_c
Date Posted: 26 April 2003 at 6:42am

thanks for the fast reply!  but I guess that wouldn't really work since I already have hundreds of members in the database

How could I change it so that when it was verfiying it remained case sensitive?

Here is the verifying part of the script:

__________________________________________________________

'Build connection with database
 set conn = server.CreateObject ("ADODB.Connection")  
 conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\home\Default\*******************************"
 set rs = server.CreateObject ("ADODB.Recordset")  
 rs.Open "SELECT * FROM admin where username='"& username &"'", conn, 1

__________________________________________________________

Thanks so much!



Posted By: ultramods
Date Posted: 26 April 2003 at 7:20am

when users are actually loggin in you would be using a query such as: "SELECT * FROM admin where username='"& username &"' AND password=' " & password " ' ",

The chances of lets say Michelle and michelle having the same password of birkett1 are quite slim. So this would be ok for your already registered members. But then you could use LCase() to make sure all new usernames are all lower case

It would be possible to check for a difference between michelle and Michelle howerver it means more coding, which thenresults in slower loading times.



Posted By: ultramods
Date Posted: 26 April 2003 at 7:45am

OK if you want to do it the way you first said you could try using.

'Build connection
 set conn = server.CreateObject ("ADODB.Connection")
 conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\home\Default\**********************"
 set rs = server.CreateObject ("ADODB.Recordset")
 'Open all records
 rs.Open "SELECT * FROM admin where username= " & username & " ' " ", conn, 3, 3 


   
IF rs.EOF THEN                                                             

        RESPONSE.WRITE("yes you can have that username")

ELSE

          RESPONSE.WRITE("sorry username taken")

END IF

If Michelle is registered it wont allow michelle to be registered.



Posted By: vicky_c
Date Posted: 26 April 2003 at 7:48am

Thanks soooooo much!  You're my saviour!!!!

I'm just gonna go try that just now!!!

Mwah! xxx

Loadsa love,
Vicky  xxx



Posted By: vicky_c
Date Posted: 26 April 2003 at 8:58am

Ok, I tried both methods and neither worked...I keep getting error messages.  I must be doing something wrong   for the first method when logging in and you search for the username and password, wot would the next line be after

"SELECT * FROM admin where username='"& username &"' AND password1=' " & password1 " ' ",

just now i have:

If not rs("username") = username AND rs("password1") = password1 then
  rs.close
  conn.close
  set rs=nothing
  set conn=nothing
  Response.Redirect("login_id.asp")
 end if

 

can u see where I have gone wrong?

Thanks for your help I really appreciate it!

 



Posted By: ultramods
Date Posted: 26 April 2003 at 9:13am

IF not rs.EOF  THEN

Response.Cookies("userLoggedIN") = username 

Response.redirect("loggedin.asp")

Else

        Response.redirect("login_id.asp")

END IF

rs.close
set rs=nothing

conn.close
set conn=nothing



Posted By: vicky_c
Date Posted: 26 April 2003 at 11:17am
Originally posted by ultramods ultramods wrote:

You could only allow users to have lower case usernames.

For example

username="ULTRAMODS"

RESPONSE.WRITE(LCase(username))

would change username to ultramods

sorry to bother you again but where would this part go?



Posted By: ultramods
Date Posted: 26 April 2003 at 11:29am
You dont need to use that part now.


Posted By: vicky_c
Date Posted: 26 April 2003 at 11:35am

I was gonna give it a try cos the otha thing neva worked   it was sayin sumthin about it cant carry out the operation cos it wasn't valid .  So if i just change the log in so that they're all lowercase now then at least it should work from now on and ill deal with the ppl who have the same usernames some other way.

Thanks! 



Posted By: ultramods
Date Posted: 26 April 2003 at 11:40am

you could do. If you are wanting to use the LCase(). You can use it in the next part of server side code that you use, after the user has entered the username.

What error message were you getting.



Posted By: vicky_c
Date Posted: 26 April 2003 at 11:51am

Well this is what I had for the full verify page:

____________________________________________________

<%
 'Save the entered username and password
 username = Request.Form("username") 
 password1 = Request.Form("password1")
 
 if username = "" then Response.redirect("empty.asp")
 if password1 = "" then Response.Redirect("empty.asp")
 
 'Build connection with database
 set conn = server.CreateObject ("ADODB.Connection")  
 conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\home\Default\****************************"
 set rs = server.CreateObject ("ADODB.Recordset")  
 rs.Open "SELECT * FROM admin where username='"& username &"' AND password=' " & password " ' ",
 
 
 IF not rs.EOF  THEN
 Session("name") = rs("fullname")
 

 else
  Resonse.Redirect("login_id.asp")
  
 end if

  rs.Close
  conn.Close
  set rs=nothing
  set conn=nothing

%>

_________________________________________________

And this is the error message I got:

ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed or invalid in this context.

/members/verify.asp, line 13

 

Line 13 is this one:

rs.Open "SELECT * FROM admin where username='"& username &"' AND password1=' " & password1 &" ' "

 

Any idea what went wrong?

Thanks so much for helping me!!



Posted By: ultramods
Date Posted: 26 April 2003 at 12:24pm

Try:

rs.Open "SELECT * FROM admin where username='"& username &"' AND password1=' " & password1 &" ' ", conn, 3, 3



Posted By: vicky_c
Date Posted: 26 April 2003 at 12:59pm
No error messages this time.....it just goes to login_id.asp even if its a valid username and password


Posted By: ultramods
Date Posted: 26 April 2003 at 1:20pm

ok. test it by using the following, to see if the variables are being passed the correct data.

RESPONSE.WRITE(username)
RESPONSE.WRITE(password1) 

Also try Trim(Request.Form("username") )

            Trim(Request.Form("password1") )



Posted By: vicky_c
Date Posted: 26 April 2003 at 1:56pm

Nope it didn't work and the lower case thing didn't work either.



Posted By: ultramods
Date Posted: 26 April 2003 at 2:11pm
can you post your entire code for that page please.


Posted By: vicky_c
Date Posted: 26 April 2003 at 3:05pm

It's ok!  I got it working! 

Thanks soooo much for all your help!!  You're a star!!!

Loadsa love,
Vicky  xxx




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net