SQL query things " I'll " is operator ll (?!)

  • Thread starter Thread starter SteveK
  • Start date Start date
S

SteveK

I have a basic selection query (SELECT * FROM Tbl WHERE
Code:
 LIKE val")
that is throwing an OleException when 'val' is the string
"It'll-be-ok"

It thinks that I'm using operator || I guess..  I dunno.  The exact error
is:

An unhandled exception of type 'System.Data.SyntaxErrorException' occurred
in system.data.dll
Additional information: Syntax error: Missing operand after 'll' operator.



I have tried removing the ''' character before the two ls, but that doesn't
solve it.  What can I try?
 
SteveK said:
I have a basic selection query (SELECT * FROM Tbl WHERE
Code:
 LIKE val")
that is throwing an OleException when 'val' is the string
"It'll-be-ok"

It thinks that I'm using operator || I guess..  I dunno.  The exact error
is:

An unhandled exception of type 'System.Data.SyntaxErrorException' occurred
in system.data.dll
Additional information: Syntax error: Missing operand after 'll' operator.

I have tried removing the ''' character before the two ls, but that doesn't
solve it.  What can I try?[/QUOTE]

Use parameters instead of embedding the value into your SQL statement.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
 
Thanks Jon,

I'm gonna scoot this train-wreck over to MSDE so that I can get some decent
sprocs up and running instead of the inline SQL... ;)






Jon Skeet said:
SteveK said:
I have a basic selection query (SELECT * FROM Tbl WHERE
Code:
 LIKE val")
that is throwing an OleException when 'val' is the string
"It'll-be-ok"

It thinks that I'm using operator || I guess..  I dunno.  The exact error
is:

An unhandled exception of type 'System.Data.SyntaxErrorException' occurred
in system.data.dll
Additional information: Syntax error: Missing operand after 'll' operator.

I have tried removing the ''' character before the two ls, but that doesn't
solve it.  What can I try?[/QUOTE]

Use parameters instead of embedding the value into your SQL statement.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
[/QUOTE]
 
SteveK said:
I'm gonna scoot this train-wreck over to MSDE so that I can get some decent
sprocs up and running instead of the inline SQL... ;)

You don't need to use stored procedures to use parameters. You can use
OleDbParameter. See OleDbCommand.Parameters for an example.
 
Back
Top