Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Syntax error (Missing Operator) in Query expression ':0:1

Syntax error (Missing Operator) in Query expression ':0:1

Scheduled Pinned Locked Moved Database
databasehelp
16 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I IgaBaro

    Hallo Forum, I am new to this forum and I would like to get your help. I am having issues with this code. HERE is the error I am getting: Syntax error (Missing Operator) in Query expression ':0:1 Dim CustomerTrans As OleDb.OleDbTransaction = Nothing Dim MyConnection As OleDb.OleDbConnection = Nothing 'Creat connection and the transactions Object Try MyConnection = New OleDb.OleDbConnection(My.Settings.dbConnectionString) MyConnection.Open() 'Begin Transaction CustomerTrans = Myconnection.BeginTransaction 'Insert the New receipt Dim SQL As String = "Insert into Receipts (ReceiptDate,ReceiptTotal) values (:0:1)" Dim CMD1 As New OleDb.OleDbCommand CMD1.Connection = Myconnection CMD1.Transaction = CustomerTrans CMD1.CommandText = SQL CMD1.Parameters.AddWithValue(":0", Now.Date) CMD1.Parameters.AddWithValue(":1", TotalPriceTxt) CMD1.ExecuteNonQuery() CMD1.Dispose() i AM Using Access 2007 and I set t ANY HELP GIVEN IS HIGHLY APPRECIATED. i TRIED ALMOST ALL I CAN THINK OF. Thank you in advance.

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #4

    What database system? Oracle? MySQL? SQL Server?

    I 1 Reply Last reply
    0
    • P PIEBALDconsult

      What database system? Oracle? MySQL? SQL Server?

      I Offline
      I Offline
      IgaBaro
      wrote on last edited by
      #5

      I am Using MS Access 2007

      P 1 Reply Last reply
      0
      • I IgaBaro

        I am Using MS Access 2007

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #6

        Maybe this will help. http://social.msdn.microsoft.com/forums/en-us/adodotnetdataproviders/thread/7974A847-5256-4B7B-9A92-8C8D5ACAB0AD[^]

        I 1 Reply Last reply
        0
        • P PIEBALDconsult

          Maybe this will help. http://social.msdn.microsoft.com/forums/en-us/adodotnetdataproviders/thread/7974A847-5256-4B7B-9A92-8C8D5ACAB0AD[^]

          I Offline
          I Offline
          IgaBaro
          wrote on last edited by
          #7

          But I am not using Named Parameters. I am really confused. I guess I have been reading way too long about this.

          P 1 Reply Last reply
          0
          • I IgaBaro

            But I am not using Named Parameters. I am really confused. I guess I have been reading way too long about this.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #8

            It looks like you think you are.

            1 Reply Last reply
            0
            • I IgaBaro

              Hallo Forum, I am new to this forum and I would like to get your help. I am having issues with this code. HERE is the error I am getting: Syntax error (Missing Operator) in Query expression ':0:1 Dim CustomerTrans As OleDb.OleDbTransaction = Nothing Dim MyConnection As OleDb.OleDbConnection = Nothing 'Creat connection and the transactions Object Try MyConnection = New OleDb.OleDbConnection(My.Settings.dbConnectionString) MyConnection.Open() 'Begin Transaction CustomerTrans = Myconnection.BeginTransaction 'Insert the New receipt Dim SQL As String = "Insert into Receipts (ReceiptDate,ReceiptTotal) values (:0:1)" Dim CMD1 As New OleDb.OleDbCommand CMD1.Connection = Myconnection CMD1.Transaction = CustomerTrans CMD1.CommandText = SQL CMD1.Parameters.AddWithValue(":0", Now.Date) CMD1.Parameters.AddWithValue(":1", TotalPriceTxt) CMD1.ExecuteNonQuery() CMD1.Dispose() i AM Using Access 2007 and I set t ANY HELP GIVEN IS HIGHLY APPRECIATED. i TRIED ALMOST ALL I CAN THINK OF. Thank you in advance.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #9

              Should there not be a comma between the two parameter identifiers like:

              Dim SQL As String = "Insert into Receipts (ReceiptDate,ReceiptTotal) values (:0, :1)"

              P I 2 Replies Last reply
              0
              • L Lost User

                Should there not be a comma between the two parameter identifiers like:

                Dim SQL As String = "Insert into Receipts (ReceiptDate,ReceiptTotal) values (:0, :1)"

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #10

                I think those just aren't valid names/markers.

                I L 2 Replies Last reply
                0
                • L Lost User

                  Should there not be a comma between the two parameter identifiers like:

                  Dim SQL As String = "Insert into Receipts (ReceiptDate,ReceiptTotal) values (:0, :1)"

                  I Offline
                  I Offline
                  IgaBaro
                  wrote on last edited by
                  #11

                  Rick Thanks for your input. I have tried that already and it didn't work for me. it gives me another error: "Data type mismatch in criteria expression" Is the anyone out the who can suggest what I should do with this error? I will really appreciate in advance. Thank you

                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    I think those just aren't valid names/markers.

                    I Offline
                    I Offline
                    IgaBaro
                    wrote on last edited by
                    #12

                    PieBALDconsult, What do you mean by not valid names? I have have them on my database exactly as you can see it. I have checked everything on the naming....is there anything you think I am missing? Please help! Thanks.

                    P 1 Reply Last reply
                    0
                    • I IgaBaro

                      PieBALDconsult, What do you mean by not valid names? I have have them on my database exactly as you can see it. I have checked everything on the naming....is there anything you think I am missing? Please help! Thanks.

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #13

                      You're more familiar with what exactly you are doing. Typically, names aren't allowed to start with a digit. My experience with Access (via OleDb) is that question marks (?) are preferred, but that names can be used if they're kept in order (as yours are). I have also only see a colon (:) used for parameter names in Oracle.

                      I 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        You're more familiar with what exactly you are doing. Typically, names aren't allowed to start with a digit. My experience with Access (via OleDb) is that question marks (?) are preferred, but that names can be used if they're kept in order (as yours are). I have also only see a colon (:) used for parameter names in Oracle.

                        I Offline
                        I Offline
                        IgaBaro
                        wrote on last edited by
                        #14

                        PIEBALD Consult, Thanks for your feedback. It really got me thinking. and I got it to work. All I had to do is take the (:) out. Man, I spent so much to do that. I really appreciate how you help me focus on where I wanted. Thank you again.

                        P 1 Reply Last reply
                        0
                        • I IgaBaro

                          PIEBALD Consult, Thanks for your feedback. It really got me thinking. and I got it to work. All I had to do is take the (:) out. Man, I spent so much to do that. I really appreciate how you help me focus on where I wanted. Thank you again.

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #15

                          I'd be interested to see what you have now.

                          1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            I think those just aren't valid names/markers.

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #16

                            I was just guessing, based on the fact that there would generally be a comma separator in such expressions. However, from the further messages it seems that OP had not checked the documentation for proper format of the command.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups