try
private void button1_Click(object sender, EventArgs e)
{
string statusCommaSeperatedValue = "1,2,3";
string storeId = "1";
DataTable dt = GetData(statusCommaSeperatedValue,storeId);
}
private static DataTable GetData(string statusCommaSeperatedValue, string storeId)
{
DataTable dt = new DataTable();
try
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=PC;Persist Security Info=True;User ID=sa;Initial Catalog=XXXX; Password=XXXXX";
string query = "select Description, Status, Loc from TableKit where IdStatus in ( @status ) and Idstore = @store";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.AddWithValue("@status", statusCommaSeperatedValue);
cmd.Parameters.AddWithValue("@store", storeId);
cmd.CommandType = CommandType.Text;
SqlDataAdapter adap = new SqlDataAdapter(cmd);
adap.Fill(dt);
}
catch (Exception ex)
{
throw;
}
return dt;
}
}