Classe de negócio (2/2)
•public static DataSet GetProducts(int cat)
•{
–string conexao = "Database=northwind;server=(local);user id=sa";
–SqlConnection conn = new SqlConnection(conexao);
–SqlCommand command = new SqlCommand();
–command.Connection = conn;
–command.CommandType = CommandType.Text;
–command.Parameters.Add(new SqlParameter("@cat", cat));
–command.CommandText = "SELECT ProductID, ProductName,
•UnitPrice, UnitsInStock FROM Products WHERE categoryID=@cat";
–SqlDataAdapter adapter = new SqlDataAdapter(command);
–DataSet ds = new DataSet();
–adapter.Fill(ds);
–return ds;
•}