First of all, it seems your original SQL can be simplified a bit to:
SELECT Products.Name AS Product,
SUM(Summary.Owned) AS Owned,
SUM(Summary.Maintained) AS Maintained,
SUM(Summary.Unlocked) AS Unlocked,
SUM(Summary.Vouchers) AS Vouchers
FROM
dbo.Summary
inner join Products on Products.ID = Summary.Product
inner join Office on Office.ID = Summary.Office
where Office.Company IN ( @Parameter)
GROUP BY Product
ORDER BY Product
But that doesn't help your problem. However, from your message it seems
that the values are Guids. This is helpful is two ways. First of all, I
really doubt you are asking your users to type in Guids, which pretty much
alleviates SQL injection problem. If you control where the value is coming
from, you can know it isn't going to hack you. Which brings us to the next
question: Then, where does that list come from? If it's coming from the DB,
you might as well just make it another join on the query.
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home:
www.noveltheory.com Work:
www.njtheater.com
Blog:
www.honestillusion.com Day Job:
www.partsearch.com
"Ben" <bent@pronamics.com.au> wrote in message
news:a33741da.0411102229.378dc0c8@posting.google.c om...[color=blue]
> Hey,
>
> Not sure if this is the right group to post this on, so sorry in
> advance if it isn't.
>
> I'm using the VS.NET 2005 beta, and am trying to fill one grid, based
> on what is selected in the other grid. So, in the SelectionChanged
> event, I get the IDs of the selected rows in the first grid, and..
> this is where i get stuck :)
>
> This is my statement:
>
> SELECT (SELECT Products.Name FROM Products WHERE Products.ID =
> Summary.Product) AS Product, SUM(Owned) AS Owned, SUM(Maintained) AS
> Maintained, SUM(Unlocked) AS Unlocked,
> SUM(Vouchers) AS Vouchers
> FROM dbo.Summary
> WHERE Summary.Office IN (SELECT Office.ID FROM Office WHERE
> Office.Company IN ( @Parameter))
> GROUP BY Product
> ORDER BY Product
>
> What I would like to be able to do, is replace @Parameter, with
> several comma seperated Guid values. However, no matter what I do, if
> i try to add a parameter, it gets interpreted as one value, and thus
> has some difficulty interpretting something two Guids seperated by a
> comma.
>
> Is there a way around this? Or do i have to manually code the this to
> use an actual SQL statement rather than trying to use parameters?
>
> Any help would be most appreciated, and I hope I've included enough
> detail.[/color]