473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

syntax error(missing operator) in query expression in an UPDATE,WHERE SQL STATEMENT.

i am working on this code for my password change option in my vb6 program. with access as backend. but im encountering errorline "syntax error(missing operator) in query expression on my update statement.

this project is very important to me and i appreciate your future comments. thanks.

Expand|Select|Wrap|Line Numbers
  1. Dim cn As New ADODB.Connection
  2. Dim sql As String
  3.  
  4. cn.Open "provider=microsoft.jet.OLEDB.4.0;Data source=C:\db1.mdb;Persist security info=true"
  5.  
  6. sql = "update userlog " & _
  7.      "set passlog= '" & txtpass.Text & "'" & _
  8.      "  where passlog= '" & txtold.Text & "'" &_
  9.      "  where user= '" & Text1.Text & "'"
  10. cn.Execute (sql)
  11. cn.Close
  12. Set cn = Nothing
Oct 3 '10 #1
5 3314
pls help!! help me about my prblem.. cant do anything about it.. oh so newbie.. :(
Oct 3 '10 #2
code green
1,726 Expert 1GB
Your query has the wrong structure.
I also recommend validating and testing the input
from the form before using in a database query.
Apart from empty values causing the query to fail,
there is also the danger of SQL injection.
Anyway replace the second WHERE with AND
Expand|Select|Wrap|Line Numbers
  1. sql = "update userlog " & _ 
  2.      "set passlog= '" & txtpass.Text & "'" & _ 
  3.      "  where passlog= '" & txtold.Text & "'" &_ 
  4.      "  AND user= '" & Text1.Text & "'" 
  5.  
Oct 4 '10 #3
oh that's why... thanks! :)
gotta ask another, if u wouldn't mind..
i have been thinking about a transaction log.
how can that be possible? i mean, if a user edited a ceratin textox, something will execute to give a value that the particular textbox has been edited. :)

sorry for a bit asking too much. thanks..
Oct 7 '10 #4
oh that's why... thanks! :)
gotta ask another, if u wouldn't mind..
i have been thinking about a transaction log.
how can that be possible? i mean, if a user edited a certain textbox, something will execute to give a value that the particular textbox has been edited. :)

sorry for a bit asking too much. thanks..
Oct 7 '10 #5
code green
1,726 Expert 1GB
It depends how important the transaction log is.
If you want to record previous and new value you are probably going to need another table to store this.

date previous new ....

But you could simply add a couple of fields to the current table 'last_updated' 'updated_by' and date stamp when and who it was edited by.
Oct 7 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: alexz | last post by:
valuA = (request.form("toadd")) If valuA = "" then SQL = "UPDATE CourseReg SET attended='Active' WHERE ID IN("&request.form("toadd")&")" Set RS = MyConn.Execute(SQL) End If MyConn.Close Set...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
4
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out...
4
by: khan | last post by:
getting, error, 3075 Syntax Error (Missing Operator) in query expression '8WHERE .=1' Dim TotalQty As Integer TotalQty = DLookup("", "", "=" & Forms!!)
3
by: access baby | last post by:
I hava a date parameter filter query but it shows error Syntax error missing operator in query experssion can some one please help where am i going wrong in expression SELECT copyorderdtl * ...
1
by: Justin R | last post by:
Hey I am really stuck and can't figure out what is wrong here is the code line and surrounding code, if anyone can help i would appreciate it. Thanks This first line is the line that has a problem...
4
by: thebarefootnation | last post by:
Hi I have the following error message "Syntax Error (missing operator) in query expression" occurring when I am trying to update combo box within a form. My code is: Dim strSQL As String
4
by: nerd4access | last post by:
Hello all! I am not new to access, but new to coding (and posting). I have a database that I have created and need some help with a login form. When a user opens the database, a form pops up...
4
by: munkee | last post by:
I am trying to dynamically update the rowsource of a chart within access. To achieve this I moved the original rowsource sql of the chart which is: SELECT tblParetoRaising.NCType,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.