473,395 Members | 2,222 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,395 software developers and data experts.

Systax Error (Missing Operator)

33
hi im reinventing a code myself but when i tried to run it didnt work as expected. i dont want to copy all the one ive downloaded so i made it a smaller by reducing the control use and not using search command.

so heres my very simple code
Expand|Select|Wrap|Line Numbers
  1. Private Sub loadrecord()
  2.  
  3.  
  4.         Dim conn As New OleDbConnection(Get_Constring)
  5.         Dim cmd As New OleDbCommand
  6.         Dim dr As OleDbDataReader
  7.  
  8.         Try
  9.             conn.Open()
  10.             cmd.Connection = conn
  11.             cmd.CommandType = CommandType.Text
  12.             cmd.CommandText = "select id, First_Name, Last_Name from table1 where id= " & Me.txtFname.Tag
  13.             dr = cmd.ExecuteReader
  14.  
  15.  
  16.  
  17.             If dr.HasRows Then
  18.                 While dr.Read
  19.                     Me.txtFname.Tag = dr("ID")
  20.                     Me.txtFname.Text = IIf(Not IsDBNull(dr("First_name")), dr("First_name"), "")
  21.                     Me.txtFname.Text = IIf(Not IsDBNull(dr("last_name")), dr("last_name"), "")
  22.  
  23.                 End While
  24.  
  25.  
  26.             End If
  27.         Catch ex As Exception
  28.             MsgBox(ErrorToString)
  29.         Finally
  30.             conn.Close()
  31.         End Try
  32.  
  33.  
  34.  
  35.  
  36.     End Sub
  37.  
  38.  

just to be honest with you, i dont understand the tag property there and some other stuff like the IIF and IsDBNull.


heres the source code i am using as my reference.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Load_Record()
  2.         Dim conn As New OleDbConnection
  3.         Dim cmd As New OleDbCommand
  4.         Dim dr As OleDbDataReader
  5.  
  6.         Try
  7.  
  8.             conn = New OleDbConnection(Get_Constring)
  9.             conn.Open()
  10.             cmd.Connection = conn
  11.             cmd.CommandType = CommandType.Text
  12.             cmd.CommandText = "select contact_id, last_name, first_name, mid_name, birth_date, gender, home_adr, bus_adr, tel_no, mobile_no, email from tblAddressBook where contact_id= " & Me.txtFirstName.Tag
  13.  
  14.             dr = cmd.ExecuteReader
  15.             If dr.HasRows Then
  16.                 While dr.Read
  17.                     Me.txtFirstName.Tag = dr("contact_id")
  18.                     Me.txtFirstName.Text = IIf(Not IsDBNull(dr("first_name")), dr("first_name"), "")
  19.                     Me.txtLastName.Text = IIf(Not IsDBNull(dr("last_name")), dr("last_name"), "")
  20.                     Me.txtMidName.Text = IIf(Not IsDBNull(dr("mid_name")), dr("mid_name"), "")
  21.                     If Not IsDBNull(dr("birth_date")) Then
  22.                         Me.dtpDOB.Format = DateTimePickerFormat.Short
  23.                         Me.dtpDOB.Value = dr("birth_date")
  24.                     End If
  25.                     If Not IsDBNull(dr("gender")) Then
  26.                         If dr("gender") = 1 Then
  27.                             Me.optMale.Checked = True
  28.                         Else
  29.                             Me.optFemale.Checked = True
  30.                         End If
  31.                     End If
  32.                     Me.txtHomeAdr.Text = IIf(Not IsDBNull(dr("home_adr")), dr("home_adr"), "")
  33.                     Me.txtBusAdr.Text = IIf(Not IsDBNull(dr("bus_adr")), dr("bus_adr"), "")
  34.                     Me.txtTelNo.Text = IIf(Not IsDBNull(dr("tel_no")), dr("tel_no"), "")
  35.                     Me.txtMobNo.Text = IIf(Not IsDBNull(dr("mobile_no")), dr("mobile_no"), "")
  36.                     Me.txtEmail.Text = IIf(Not IsDBNull(dr("email")), dr("email"), "")
  37.                 End While
  38.             End If
  39.  
  40.         Catch ex As Exception
  41.             MsgBox(ErrorToString)
  42.         Finally
  43.             conn.Close()
  44.         End Try
  45.     End Sub
  46.  
  47.  
  48.  
Thanks . ill be attaching my sample work here.
Attached Files
File Type: zip CRUD.zip (94.7 KB, 52 views)
Oct 14 '14 #1

✓ answered by iam_clint

you are selecting id but trying to get ID, not sure but probably a case sensitivity issue there.
Expand|Select|Wrap|Line Numbers
  1. select id, 
  2.  Me.txtFname.Tag = dr("ID")
  3.  
IIF stands for inline if.
http://msdn.microsoft.com/en-us/libr...=vs.90%29.aspx

dbnull
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx

tag
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx

1 1145
iam_clint
1,208 Expert 1GB
you are selecting id but trying to get ID, not sure but probably a case sensitivity issue there.
Expand|Select|Wrap|Line Numbers
  1. select id, 
  2.  Me.txtFname.Tag = dr("ID")
  3.  
IIF stands for inline if.
http://msdn.microsoft.com/en-us/libr...=vs.90%29.aspx

dbnull
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx

tag
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx
Oct 14 '14 #2

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

Similar topics

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"...
3
by: Mark | last post by:
Hi - I can get this to work in SQL Server - but when also trying to make the application compatible with MS Access I get an error: Select tblfaqnetgroups.group_name from tblfaqnetroles Inner...
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...
1
by: Alan Murrell | last post by:
Hello, One of our web hosting clients is getting the following error when someone tried to log in form their login page: --- ODBC ERROR --- Microsoft OLE DB Provider for ODBC Drivers error...
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!!)
1
by: chug | last post by:
I'm not a programmer but it's my job to solve this. Can someone help me with this error message? Microsoft OLE DB Provider for ODBC Drivers error '80040e14' Syntax error (missing operator)...
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 * ...
3
by: Margie | last post by:
Working on my database I use a modified piece of code gotten from thescripts. The code works perfectly except for one thing. When entering data containing the character ' , I get the error: Syntac...
2
by: Dilip Krishnan | last post by:
Syntax error (missing operator) in query expression 'Serial Number = 'L3FW341''. The Serial Number field is declared as text in Access Db. I am not sure which operator is missing in my command! ...
2
by: pptechs | last post by:
Hello. In dying need of assistance. All I am trying to do is search a table for a valid user ID for a form login screen and I am getting error : "Run-time error 3075 syntax error (missing...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.