I have a list List<Int32>
containing ids and want to select some values from another table where id=ids[0],ids[1],...
it look like this:
string query=String.Format("@ SELECT values from Table WHERE id=???");
How to get result?
P.S. as i listen- that this way is not right.
So, another way to do that- use Join:
string queryString = String.Format(@" SELECT * FROM Table1 [t1]
join [Table2] [t2]
on [t1].idTable1=[t2].id where [idParamValue]={0}", idParamValue);
So, then i should use :
using (var sqlCmd = new SqlCommand(queryString, _connection))
{
using (var sqlReader = sqlCmd.ExecuteReader())
{
while (sqlReader.Read())
{
var param1=(String)sqlReader["param_name"];
}
}
}
Thank you!