🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
3 messages
3 total messages Started by Stephane Baillargeon Mon, 29 May 2006 19:51
ADO SQL Parameters
#478
Author: Stephane Baillargeon
Date: Mon, 29 May 2006 19:51
34 lines
1543 bytes
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?
Re: ADO SQL Parameters
#479
Author: Stephane Baillargeon
Date: Mon, 29 May 2006 21:00
37 lines
1786 bytes
I found it... WHERE Field1 IN (':List')

Stephane Baillargeon wrote:
> 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?
Re: ADO SQL Parameters
#480
Author: Viatcheslav V. Vassiliev
Date: Mon, 29 May 2006 21:46
51 lines
2458 bytes
I am not sure that you can pass 5, 4, 3 as one parameter. Your solution may 
look for string '5,4,3' but not for 3 numbers.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)


"Stephane Baillargeon" <stephane_baillargeon@sympatico.ca> ???????/???????? 
? ???????? ?????????: news:447b60f5$1@newsgroups.borland.com...
>I found it... WHERE Field1 IN (':List')
>
> Stephane Baillargeon wrote:
>> 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? 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads