Click here to Skip to main content
       

Database

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionSyntax error (Missing Operator) in Query expression ':0:1memberIgaBaro23 Jan '13 - 14:40 
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 'Blush | :O :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 (Blush | :O :1)"
Dim CMD1 As New OleDb.OleDbCommand
CMD1.Connection = Myconnection
CMD1.Transaction = CustomerTrans
CMD1.CommandText = SQL
CMD1.Parameters.AddWithValue("Blush | :O ", 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.

AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberMycroft Holmes23 Jan '13 - 15:02 
Read this article [^](I know it is long but you can skip to the parameterised query section) it will answer your question and give you additional information on sql.
Never underestimate the power of human stupidity
RAH

GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23 Jan '13 - 15:25 
RAH
 
Thanks for the quick response. Although I have learned something new in the article you posted, I still can't find what the problem is with my code.
What am I doing wrong? it looks valid syntax to me, but what do I know, I am new to this. I have been reading about INSERT INTO statement all day long and can't find whats wrong with my code.
 
Thanks
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23 Jan '13 - 15:37 
What database system? Oracle? MySQL? SQL Server?
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23 Jan '13 - 16:16 
I am Using MS Access 2007
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23 Jan '13 - 16:26 
Maybe this will help.
 
http://social.msdn.microsoft.com/forums/en-us/adodotnetdataproviders/thread/7974A847-5256-4B7B-9A92-8C8D5ACAB0AD[^]
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23 Jan '13 - 16:58 
But I am not using Named Parameters. I am really confused. I guess I have been reading way too long about this.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23 Jan '13 - 16:59 
It looks like you think you are.
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmvpRichard MacCutchan23 Jan '13 - 23:22 
Should there not be a comma between the two parameter identifiers like:
Dim SQL As String = "Insert into Receipts (ReceiptDate,ReceiptTotal) values (:0, :1)"

GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult24 Jan '13 - 5:48 
I think those just aren't valid names/markers.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro24 Jan '13 - 5:54 
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.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult24 Jan '13 - 6:00 
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.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro24 Jan '13 - 7:11 
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 (Smile | :) out. Man, I spent so much to do that.
 
I really appreciate how you help me focus on where I wanted.
 
Thank you again.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult24 Jan '13 - 7:56 
I'd be interested to see what you have now.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmvpRichard MacCutchan24 Jan '13 - 22:35 
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.
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro24 Jan '13 - 5:51 
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

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 25 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid