 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Stephane Baillargeon Guest
|
Posted: Tue May 30, 2006 1:53 am Post subject: SQL Params |
|
|
I'm trying to add a string as a parameter in a SQL query statement like
this:
ConnectionString is already taken care of and not shown here.
TADOQuery *padoQry = new TADOQuery( NULL );
AnsiString strList = "(5,4,3)";
padoQry->SQL->Clear();
padoQry->SQL->LoadFromFile( SQLFILE ); // (e.g.: "sqlfile.sql")
padoQry->Parameters->Clear();
padoQry->Parameters->AddParameter();
padoQry->Parameters->Items[0]->Value = strList;
padoQry->Open();
// Error --> 'In operator without () in query expression...
SQL FILE
SELECT Field1, Field2
FROM Table1
WHERE Field1 IN :List
I've tried this too without success
SELECT Field1, Field2
FROM Table1
WHERE Field1 IN ( :List ) // :List == "5,4,3"
Is there something I'm doing wrong? |
|
| Back to top |
|
 |
Stephane Baillargeon Guest
|
Posted: Tue May 30, 2006 1:59 am Post subject: Re: SQL Params |
|
|
I found it... WHERE Field1 IN (':List')
Stephane Baillargeon wrote:
| Quote: | I'm trying to add a string as a parameter in a SQL query statement like
this:
ConnectionString is already taken care of and not shown here.
TADOQuery *padoQry = new TADOQuery( NULL );
AnsiString strList = "(5,4,3)";
padoQry->SQL->Clear();
padoQry->SQL->LoadFromFile( SQLFILE ); // (e.g.: "sqlfile.sql")
padoQry->Parameters->Clear();
padoQry->Parameters->AddParameter();
padoQry->Parameters->Items[0]->Value = strList;
padoQry->Open();
// Error --> 'In operator without () in query expression...
SQL FILE
SELECT Field1, Field2
FROM Table1
WHERE Field1 IN :List
I've tried this too without success
SELECT Field1, Field2
FROM Table1
WHERE Field1 IN ( :List ) // :List == "5,4,3"
Is there something I'm doing wrong? |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|