Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2004, 01:44 PM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default Please Help me about UPDATE query

This is my code
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:
quote:Run time Error '3061':
Quote:
Too few Paramenters . Expected 1
I don't know how to fix it . Anybody please help me ?
Thanks very much

 
Old September 23rd, 2004, 02:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
 
Old September 24th, 2004, 06:55 AM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default

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.

 
Old September 24th, 2004, 12:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

I dont understand your error...

you said that this:
Code:
db.execute "UPDATE Users SET Password = '" & text1.text & "'"
dont work???

HTH

Gonzalo
 
Old September 24th, 2004, 02:17 PM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default

I said that this code can not be run
 
Quote:
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 .
 
Old September 27th, 2004, 09:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
 
Old September 27th, 2004, 01:20 PM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default

My code has been run now . Only one field because....my application need only one password to run it :)
Thanks sir bmains very much .

 
Old September 28th, 2004, 02:29 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma
Default

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
 
Old September 29th, 2004, 03:45 AM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default

yeah . You a right . Thank Sir About your suggest .






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Query Help dalezjc Classic ASP Basics 8 March 18th, 2008 08:49 AM
Update Query rsm42 ASP.NET 1.0 and 1.1 Basics 0 April 9th, 2007 09:32 AM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Update query trab Access 1 May 11th, 2006 03:58 PM
Update query edcaru Access 3 June 14th, 2004 03:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.