Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Multiple Values to a Single Parameter?
Message
De
20/09/2004 03:32:42
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Passing Multiple Values to a Single Parameter?
Divers
Thread ID:
00943913
Message ID:
00943913
Vues:
66
Hi ol!

I need to used the following statement in a stored procedure:

Select * from Fruits where FruitName in ('Apple', 'Banana', 'Coconuts')

Apple, Banana, & Coconut are values that will be supplied by the user using a listbox which allows multiple selection. There is no limit on the number of items that the user can select. It can be 1 or 10 or more. Is there a way I can pass these values into a single paramter so I can use it like:

Select * from Fruits where FruitName in (@Parameter)

I have tried putting all the values in a single variable formated for the IN clause.

x="'Apple', 'Banana', 'Coconut'"

Passing this to the stored procedure generates an error "To many parameters passed!" which is true because when...

cn.Execute("spFruit " & x)

... is evaluated it looks like...

cn.Execute("spFruit 'Apple', 'Banana', 'Coconut'")

... which passed 3 parameters to spFruit which only accepts 1 parameter. Anyone with ideas on how I can tackle this?

Thanx! a lot in advance!!! :)
Shit happens!!!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform