Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

odbc: binding array as parameter

Status
Not open for further replies.

VBmim

Programmer
Jun 25, 2001
361
BE
Hello,

I would like to bind an array as a parameter for an odbc command object. I would like to build the query

select * from T where T.col in (1,2,3,4,5,6,7,8,9,10);

where the list for T.col is combined in 1 parameter...

Is this possible?

Kind greetings,

Mim
 
I had to do something like this resent, I converted the list (or could be an array) into a comma delimited string and passed that over as a varchar into the stored procedure.
 
you cannot pass a collection as a single parameter. each value is separate parameter. there are ways to parse a string into a table on the database side and use joins/sub-selects, but this is specific to each database server.

I would recommend using an ORM framework to manage all the sql conversion for you. this makes it much easier to write queries using an object model rather than tsql.

NHibernate, ActiveRecord and LLBL($) are the popular ones.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for your responses.

I already passed the values as a string but I was wondering if you could pass an array without having to build the string first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top