|
Subject:
|
Please Help me about UPDATE query
|
|
Posted By:
|
huyremy
|
Post Date:
|
9/23/2004 1:44:20 PM
|
This is my code
Dim db As Database
Private Sub Command1_Click()
newpass = Text1.Text
db.Execute "UPDATE Users SET Password =" & newpass
MsgBox " Password Has Been Change "
End Sub
Private Sub Form_Load()
Set db = OpenDatabase("msmo.mdb")
End Sub
And this is my Problem : I use my form to change the Password Feild in my database But IF my string is number . That code run very well but If my String is Text or Text and Number I get this error quote: Run time Error '3061': Too few Paramenters . Expected 1
I don't know how to fix it . Anybody please help me ? Thanks very much
|
|
Reply By:
|
bmains
|
Reply Date:
|
9/23/2004 2:31:52 PM
|
Hey,
For your query, you need to put string params in single quotes, and numbers with no quotes:
update Users set Password = 'Password', NumberField = 1
Also, you need to have a where clause, or all fields will be updated with the password:
db.Execute "update Users set Password='" & newpass & " where userid = '" & userid & "'"
Brian
|
|
Reply By:
|
huyremy
|
Reply Date:
|
9/24/2004 6:55:38 AM
|
Hello Sir ! My database has only one Field is Password (Field(0)) So I try to use that query like db.Execute "UPDATE Users SET Password ='newpass'" But my code can't get value from textbox in my form which is Text1.Text Can you help me again ? Thanks Sir very much.
|
|
Reply By:
|
gbianchi
|
Reply Date:
|
9/24/2004 12:15:29 PM
|
hi there..
I dont understand your error...
you said that this:
db.execute "UPDATE Users SET Password = '" & text1.text & "'"
dont work???
HTH
Gonzalo
|
|
Reply By:
|
huyremy
|
Reply Date:
|
9/24/2004 2:17:16 PM
|
I said that this code can not be run quote: db.Execute "UPDATE Users SET Password ='newpass'"
Not Your code can't be run . But Thanks sir gbianchi and sir bmains ! My Code now has been run very well . Thanks again . Wish that you can help me more in the future .
|
|
Reply By:
|
bmains
|
Reply Date:
|
9/27/2004 9:24:52 AM
|
Hey,
Why only one field in the database? How do you know who's password is what? Or is this an application password.
Are you still getting the same error? I don't see anything wrong with that statement. By the way, what is the database (db) object?
Brian
|
|
Reply By:
|
huyremy
|
Reply Date:
|
9/27/2004 1:20:27 PM
|
My code has been run now . Only one field because....my application need only one password to run it :) Thanks sir bmains very much .
|
|
Reply By:
|
Anantsharma
|
Reply Date:
|
9/28/2004 2:29:56 AM
|
Hi,
Thats good to know that ur prob is solved.
I suggest u to use ADO (I feel u r using DAO). Else are the things related to some good programming techniques u should follw while coding. ADO RecordSets and connection Objects are very flexible.
Best of luck.
B. Anant
|
|
Reply By:
|
huyremy
|
Reply Date:
|
9/29/2004 3:45:10 AM
|
yeah . You a right . Thank Sir About your suggest .
|