Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Multiple Values to a Single Parameter?
Message
 
 
À
20/09/2004 03:32:42
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00943913
Message ID:
00943958
Vues:
22
This message has been marked as a message which has helped to the initial question of the thread.
Thre's more than one way to acomplish that. Using XML is my favorite. See Re: Variable IN Message #834232

>
>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?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform