Joaquim,
You definitely need to handle this with a Stored Proc and pass your list in as one Parameter.
In your Stored Proc, there are a couple ways to handle this.
Kevin Goff has a solution at this Message #
1220992 ... he uses an XML approach. In this approach your Parameter would be an XML string (assuming you're using SQL Server 2005).
Another way to handle it is to use dynamic SQL in your Stored Proc with your parameter being the comma-delimited list, something like this:
declare @SelectStatement varchar(100)
Set @SelectStatement = 'select unidade, numero, date ' +
execute (@SelectStatement)
~~Bonnie
>Thank you Viv, but i don't know how many parameters i need. That's the reason i don't send the parameter list separately.
>The user creates a list of codes, and i send this list as parameters to the database.
>
>One solution would be creating a memory DataTable internally, and then join the DataTable to the Database table. Something like this:
>
>
>DataTable dt = new DataTable("Table1");
>dt.Columns.Add("unidade");
>DataRow dr = dt.NewRow();
>dr["unidade"]= "1234";
>dt.Rows.Add(dr);
>dt.AcceptChanges();
>.
>.
>.
>dr["unidade"]= "9999";
>dt.Rows.Add(dr);
>dt.AcceptChanges();
>
>
>Once i had this table i could create a select string like this:
>
>
>SelectString = "select a.unidade, a.numero, a.date " +
> "from _dsa_ihs_table a, 'Table1' b" +
> "where a.unidade = b.unidade " +
> "order by a.unidade" ;
>
>
>But for that i know there's no way to do this. Or there is?
>
>Joaquim
>
>
>>Hi,
>>
>>
>>You'd need to pass the parameters in seperately:
>> "where unidade in (?,?,?,?, etc) " +"
which isn't particularly practical. Maybe pass the SParameter to a SP instead?
>>Regards,
>>Viv