Wednesday, March 21, 2012

Quotes within a query

Help, please.

I'm going crazy trying to figure out how to form this SQL query. I am querying an Informix linked server and I need to pass a variable date. I am using an expression to create the query like so

"Select count(*) from " + @.[User::varDBName] + ":informix.doc_tl WHERE " + @.[User::varDBName] +":informix.doc_tl.d_received = {D " + @.[User::varDate] +"} "

The informix query needs the date to be {D "2007-01-15"} but for the life of me, I can't get the date enclosed in quotes.

The error I get is

An OLE DB record is available. Source: "(null)". HResult: 0x80040E14

Description: "(null)"

Can anyone tell me what I'm doing wrong?

Thanks

Hi Chris,

Can you try using single quote character (') or escaped quote character i.e. using quote twice ("")?

-- Waseem

|||

Hi!

Thanks for the reply. I thought I tried both but upon retry, the single quote character worked. I do get a code page warning but I think that is OK.

Thanks so much!

No comments:

Post a Comment