473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

strcompair and sql

I have an Sql statment I need to do a case sensitive compair on and I don't know how to do the case sensitive compair I Have seen examples here but I didn't have a luck getting an answer I could work with , could some one make the appropiate changes to my sql statment for the case sensitive compair so I can see how it works :
Expand|Select|Wrap|Line Numbers
  1.  vba:
  2. Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [PsWrdTbl] WHERE" _
  3. & " [password]= '" & Me.[Password] & "' AND [Name]= '" & Me.[Tech. Name] & "';")
  4.  
Thanks for helping.
Mar 22 '08 #1
6 1300
ADezii
8,834 Expert 8TB
I have an Sql statment I need to do a case sensitive compair on and I don't know how to do the case sensitive compair I Have seen examples here but I didn't have a luck getting an answer I could work with , could some one make the appropiate changes to my sql statment for the case sensitive compair so I can see how it works :
Expand|Select|Wrap|Line Numbers
  1.  vba:
  2. Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [PsWrdTbl] WHERE" _
  3. & " [password]= '" & Me.[Password] & "' AND [Name]= '" & Me.[Tech. Name] & "';")
  4.  
Thanks for helping.
To perform an exact, Binary Comparison ("Philadelphia" <> "philadelphia"), you would have to incorporate something similar to that below into the Where Clause of the SQL String:
Expand|Select|Wrap|Line Numbers
  1. 'Assuming [Tech Name] is a String
  2. Where StrComp([Password], Me![Password], vbBinaryCompare) = 0 And [Name] = '" & Me![Tech Name] & "';"
Mar 22 '08 #2
Thanks I am in the process of trying your post reply out, but I forgot how do I set a password complexity sting , so that the user can change their password
Ie password must 7 - 10 charicture long and must contain 2 special characters (special chacters being: !,@,#,$,%,^,&,*, 1 captital leter. but they can appear in any order in the password
thanks for helping.
Mar 22 '08 #3
Expand|Select|Wrap|Line Numbers
  1. Dim qryDB As DAO.Database
  2. Dim loRst As DAO.Recordset
  3. With loRst
  4. Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [PsWrdTbl] WHERE strComp(" _
  5. & " [password], Me.[Password], vbBinaryCompare) = 0 AND [Name]= '" & Me.[Tech. Name] & "';")
  6. tstr = .Fields("password")
  7.  
  8. If loRst.RecordCount > 0 Then MsgBox "we have a match"
  9. If loRst.RecordCount = 0 Then MsgBox "no match"
  10. End With
  11.  Set loRst = Nothing
  12.     loRst.Close
  13.  
This doesn't seem to be working , I have a text box set up for testing to return the password from the db and also generate a msg if recordcount is greater that 0 and nother message if recordcount is less than 0
and niether mesgbox's will generate and the textbox stays blank
FYI: tech. Name is a string
Mar 22 '08 #4
ADezii
8,834 Expert 8TB
I have an Sql statment I need to do a case sensitive compair on and I don't know how to do the case sensitive compair I Have seen examples here but I didn't have a luck getting an answer I could work with , could some one make the appropiate changes to my sql statment for the case sensitive compair so I can see how it works :
Expand|Select|Wrap|Line Numbers
  1.  vba:
  2. Set loRst = CurrentDb.OpenRecordset("SELECT * FROM [PsWrdTbl] WHERE" _
  3. & " [password]= '" & Me.[Password] & "' AND [Name]= '" & Me.[Tech. Name] & "';")
  4.  
Thanks for helping.
I've changed my trend of thought on this Password Thread since it must meet different criteria levels. The code will actually act as Validations for saving Passwords to PsWrdTbl:
  1. Not only must the Password Match the value in the Text Box, it must be a Binary Match (case sensitive).
  2. Its length must be >= 2 and <= 10.
  3. It must contain at least 2 Special, pre-defined characters
Expand|Select|Wrap|Line Numbers
  1. Dim strPassword As Variant
  2. Dim intCounter As Integer
  3. Dim intNumOfSpecChars
  4. Const strSpecialChars As String = "!@#%^&*"
  5.  
  6. intNumOfSpecChars = 0       'Initialize
  7.  
  8. If IsNull(Me![Password]) Then Exit Sub
  9.  
  10. strPassword = Nz(DLookup("[Password]", "PsWrdTbL", "[Password] = '" & Me![Password] & "'"), "")
  11.  
  12. If Len(strPassword) > 0 Then        'Test #1, a Password does exist
  13.   If StrComp(strPassword, Me![Password], vbBinaryCompare) = 0 Then    'Test #2, is Password an "exect" Match
  14.     If Len(strPassword) >= 2 And Len(strPassword) <= 10 Then      'Test #3, length of Password >=2 and <=10
  15.       For intCounter = 1 To Len(strSpecialChars)
  16.         'Test #4, at least 2 special characters as defined by Const strSpecialChars
  17.         If InStr(strPassword, Mid$(strSpecialChars, intCounter, 1)) > 0 Then
  18.           intNumOfSpecChars = intNumOfSpecChars + 1
  19.         End If
  20.       Next
  21.       If intNumOfSpecChars < 2 Then
  22.         MsgBox "Password is missing some special characters!"
  23.       Else
  24.         'If you ever get here, you have a valid Password meeting all 4 conditions
  25.         MsgBox "Bravo"
  26.       End If
  27.     Else
  28.       MsgBox "Password is not the proper length!"
  29.     End If
  30.   Else
  31.     MsgBox "Your Password is no an exact Match!"
  32.   End If
  33. Else
  34.   MsgBox "Invalid Password!"
  35. End If
Mar 23 '08 #5
WOW, thanks for the code,I was looking an IntStr and for somreason never crossed my mind to use a counter on predefined special characture.
I hav't tried the code yet, I'm still putting together the login screen, where if they login correctly then they can change there password (I've made it not so easy to login though I did a binary compare on both the username in the field against the table as well as the password
Thanks for your help agpin.
Side note: I plan to allow the user to change password like on windows logonscreen , where user must enter the "old" password, then the new password twice
Mar 25 '08 #6
ADezii
8,834 Expert 8TB
WOW, thanks for the code,I was looking an IntStr and for somreason never crossed my mind to use a counter on predefined special characture.
I hav't tried the code yet, I'm still putting together the login screen, where if they login correctly then they can change there password (I've made it not so easy to login though I did a binary compare on both the username in the field against the table as well as the password
Thanks for your help agpin.
Side note: I plan to allow the user to change password like on windows logonscreen , where user must enter the "old" password, then the new password twice
Glad to help you Trevor. Just keep in mind that all the preceeding code is useless if the same Validations are not applied when the User atempts to Save a Password. It should pass similar Tests prior to be saved in the Table. Take care.
Mar 25 '08 #7

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.