BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL Params

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Stephane Baillargeon
Guest





PostPosted: Tue May 30, 2006 1:53 am    Post subject: SQL Params Reply with 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
Stephane Baillargeon
Guest





PostPosted: Tue May 30, 2006 1:59 am    Post subject: Re: SQL Params Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.