|
-
July 17th, 2012, 12:57 AM
#1
"Unclosed quote character mark before.." on updating crypted password to SQl
hi guys,i'm new in this forums hope it can help me to solve my problem.. 
anyway, i have a code for Encrypting passwords...
but i dont know why for some combination of words(like IS) it show "Unclosed character string " when updating the Crypted text to SQl..
here's my code
Code:
Public Function IsChangePassword(ByVal user As String, ByVal oldPasswd As Object, _
ByVal newPasswd As Object, ByVal retype As Object) As Boolean
On Error GoTo HELL
Dim sOldPasswd$, sNewPasswd$, sRetype$
Dim sSQl As String
Dim rec As New ADODB.Recordset
sOldPasswd = Crypt(oldPasswd)
sNewPasswd = Crypt(newPasswd)
sRetype = Crypt(retype)
sSQl = ""
sSQl = sSQl & " select count(*) from t_username "
sSQl = sSQl & " where user_name = " & QuoteStr(user)
sSQl = sSQl & " and user_passwd = " & QuoteStr(sOldPasswd)
Set rec = conn.Execute(sSQl)
If rec.Fields(0) = 0 Then
IsChangePassword = False
MsgBox "Old password does not match !", vbInformation, "Change Password"
oldPasswd.SetFocus
Exit Function
End If
If sNewPasswd <> sRetype Then
IsChangePassword = False
MsgBox "Retype new password does not match !", vbInformation, "Change Password"
retype.SetFocus
Exit Function
End If
sSQl = ""
'sSQL = sSQL & " update t_username set user_passwd = " & QuoteStr(sNewPasswd) & " where user_name = " & QuoteStr(user)
sSQl = sSQl & " update t_username set user_passwd = '" & sNewPasswd & "' where user_name = '" & user & "'"
ExecuteSQL sSQl, False
IsChangePassword = True
MsgBox "Password successfully changed !", vbInformation, "Change Password"
Set rec = Nothing
HELL:
If Err.Number <> 0 Then
IsChangePassword = False
Call LogActivities(Now(), "", Err.Number, Err.Source, Err.Description, "IsChangePassword() As Boolean", App.Major & "." & App.Minor & "." & App.Revision, "user As String, oldPasswd As Object, newPasswd As Object, retype As Object", vTypeError)
MsgBox Err.Description, vbCritical, "IsChangePassword @ " & App.Title & ".cGenUser"
Set rec = Nothing
Exit Function
End If
but when i use the Sql Code for updating pass to SQl in Query analizer it works fine,,
but why when VB catch an err. message on it.. ??
Plz help..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|