using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
/// <summary>
/// Summary description for Produtos
/// </summary>

namespace AlfredoLotar.Livro.Aspnet
{
    public class Produtos
    {
        public Produtos() { }

        public DataView GetProdutos()
        {
            ConnectionStringSettings getString = WebConfigurationManager.ConnectionStrings["nwind"] as ConnectionStringSettings;
            if (getString != null)
            {
                string sSql = "Select ProductName from Products";
                using (SqlConnection conn = new SqlConnection(getString.ConnectionString))
                {
                    DataSet ds = new DataSet();
                    SqlDataAdapter adapter = new SqlDataAdapter(sSql, conn);
                    adapter.Fill(ds, "Produtos");
                    DataView dv = ds.Tables[0].DefaultView;
                    return dv;
                }
            }
            return null;
        }
    }
}
