Results 1 to 5 of 5

Thread: case sensitive SQL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Talking

    Is it possible to make a SELECT statment case-sensitive? For example, is it possible to have a statment like

    Code:
    rsCountry.Open "Select * From Countries Where COUNTRY = '" & txtCountry.text & "'", myCN, adOpenKeyset, adLockReadOnly
    where, if txtCountry.text = 'France', the recordset would return 'France' but not 'FRANCE'?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Yes there is.

    You need to compare the ACTUAL values of the characters rather than the symbolic fact of what letter it is.

    Therefor you need to convert the things you are comparing to a variable length BINARY field (The equivalent of comparing actual ASCII values instead of letters)

    Code:
    rsCountry.Open "Select * From Countries Where CONVERT(varbinary,COUNTRY) = CONVERT(varbinary,'" & txtCountry.text & "')", myCN, adOpenKeyset, adLockReadOnly

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Unhappy

    Gen-X, I tried your example. The recordset is actually a table of previously used passwords, so the recordset looks like:
    Code:
    rsPasswords.Open "Select * From Passwords Where IdUSUARIO = " & _
      rsUsers.Fields("IdUSER").Value & " And CONVERT(varbinary, PASSWORD) = CONVERT(varbinary, '" & _
      txtPassword(1).Text & "')", myCN, adOpenKeyset, adLockReadOnly
    But it gives me the error that the function CONVERT is not defined in the expression.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Sounds like you are not using SQL Server but perhaps Access or something else.

    In that case you have to find a similar function in the SQL help of the database you are using that allows you to convert between datatypes.

    You want to get away from strings and into a format that is binary in nature so that you compre the actual values and not the string "logical" values.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    YOu are right, I am using Access. There is probably some similiar function in Access, though, so I will check the Help sections.

Posting Permissions

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



Click Here to Expand Forum to Full Width