-
February 10th, 2013, 01:05 AM
#1
[RESOLVED] Change Password Error
Hello Sir,
I am Create login form then change password form.. Heres my code
i dont get it what is the problem of my code, VB 6 Say: Syntax Error Upadate Statement
Code:
Private Sub cmdOk_Click()
Dim rs As New ADODB.Recordset
Dim change As String
If txtOld.Text = Login.txtPassword.Text Then
rs.Open "Select Password From tblUser where UserID = '" & MDIForm1.id.Caption & "'", acd, adOpenForwardOnly
change = "UPDATE tblUser SET Password ='" & txtNew.Text & "' where UserID = '" & MDIForm1.id.Caption & "'"
acd.Execute change
MsgBox "Change"
Else
MsgBox "Invalid Old Password"
End If
End Sub
Help me sir thanks
-
February 10th, 2013, 01:11 AM
#2
Re: Change Password Error
The only thing that jumps out at me in that line is that you are using Password as a field name which is something you should not be doing, Password is a reserved word. You should as a general rule avoid using any reserved words, spaces or special characters in field names. Of course sometimes the design of the tables is out of our control in which cases you need to use the trusty little [ ] trick
Code:
change = "UPDATE tblUser SET [Password] ='" & txtNew.Text & "' where UserID = '" & MDIForm1.id.Caption & "'"
Is there a reason that you are using a select statement before the update there? I can't see any reason why you would do this in that piece of code. You are not doing anythign with it and then you are changing it 2 lines later so whatever is in that recordset would not be what is now in the database...
Always use [code][/code] tags when posting code.
-
February 10th, 2013, 01:22 AM
#3
Re: Change Password Error
Thanks.. Run Perfectly.. ^_^
Tags for this Thread
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
|