Can someone help me solve this visual basic 6.0 / SQL statement error I am getting?

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2009
Posts: 3
Reputation: jreeson is an unknown quantity at this point 
Solved Threads: 0
jreeson jreeson is offline Offline
Newbie Poster

Can someone help me solve this visual basic 6.0 / SQL statement error I am getting?

 
0
  #1
Mar 18th, 2009
I am running the following Update Query in my program and I am encountering the following Error:

Run-time error '2147217900 (80040e14)':
Syntax error in UPDATE statement

Here is the code i am running

My module contains the following code:

Public UserName As String
Public UpdatePassword As String
Public rsUpdateUserQuery As Recordset

Public Sub runUpdateUserQuery()
Set rsUpdateUserQuery = New ADODB.Recordset
rsUpdateUserQuery.Open sqlUpdateUserQuery, cnConnection, adOpenDynamic
End Sub

This is the procedure that is causing the error above, I am trying to update the User's Passwords in my database. I use a similar UPDATE statement for all other User related fields but for some reason this is the only one causing a problem. As far as I can see they are all the same. The Password and Username fields in my database are both Text data types. The program grabs the user info from the form and put it into the corresponding 'Update___' variables. These variables are then used in the UPDATE statements.

sqlUpdateUserQuery = "UPDATE tblUSERS SET Password = '" & UpdatePassword & "'" & " WHERE UserName = '" & UserName & "' "

runUpdateUserQuery

The issue always happens after executing runUpdateUserQuery.
Any help or suggestions would be greatly appreciated!
Cheers
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 65
Reputation: arvin2006 is an unknown quantity at this point 
Solved Threads: 4
arvin2006's Avatar
arvin2006 arvin2006 is offline Offline
Junior Poster in Training

Re: Can someone help me solve this visual basic 6.0 / SQL statement error I am gettin

 
0
  #2
Mar 19th, 2009
JUST TRY THIS.

sqlUpdateUserQuery = "SELECT * FROM tblUSERS WHERE UserName = '" & UserName & "' "
Set rsUpdateUserQuery = New ADODB.Recordset
rsUpdateUserQuery.Open sqlUpdateUserQuery, cnConnection, adOpenDynamic

With rsUpdateUserQuery
.Fields("FieldName")=txtName.Text
.Fields(FieldName2")=txtName2.Text
.Update
End With
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3
Reputation: jreeson is an unknown quantity at this point 
Solved Threads: 0
jreeson jreeson is offline Offline
Newbie Poster

Re: Can someone help me solve this visual basic 6.0 / SQL statement error I am getting?

 
0
  #3
Mar 19th, 2009
Thanks so much,

I implemented your recommendation and added 'adLockOptimistic' to my recordset.open procedure and it is working perfectly now.

Cheers!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC