case sensitive search

Results 1 to 3 of 3

Thread: case sensitive search

  1. #1
    Join Date
    Dec 1969

    Default case sensitive search

    how do i do a case sensitive comparison of text? i'm using asp-VBScript -Access. during the user login, irrespective of the case of the username and password, login is allowed. how can i restrict this? for eg, in my database, the username="Andy" and password="aaa" but during login, even if i enter aNdy or ANDY etc and AAA or Aaa etc i can login

  2. #2
    Join Date
    Dec 1969

    Default Upper...

    select username,pwd from usertable where UPPER(username) = Upper(&#039;" & request("username") & "&#039;)"<BR><BR>But I think u should allow the user name to be non case-sensitive, password should be case sensitive, anyway its your call.

  3. #3
    Jeremy_D Guest

    Default RE: case sensitive search

    The best way of doing case-sensitive comparisons on a case-insensitive installation is casting your char/varchar to binary/varbinary:<BR><BR>IF Cast(@password AS varbinary) = SELECT Cast(Password AS varbinary) FROM tblUsers WHERE Cast(Username AS varbinary(50)) = Cast(@username AS varbinary(50)) BEGIN<BR>/* Case-sensitive Login OK */<BR>END ELSE BEGIN<BR>/* Case-sensitive Login invalid */<BR>END<BR><BR>This is also the way to go if you want to order data case-sensitive on a case-insensitive installation:<BR>SELECT * FROM MyTable ORDER BY Cast(FieldName AS varbinary)<BR>- or -<BR>SELECT * FROM MyTable ORDER BY FieldName, Cast(FieldName AS varbinary)<BR><BR>- the latter will allow the usage of an index on FieldName<BR><BR>Remember that the default length for varbinary/varchar is 30, so if your max password length is bigger then that you&#039;ll have to change the above example to Cast(@password AS varbinary(x)) where x is the max password length.<BR><BR>Jeremy_D<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts