views:

110

answers:

3

I'm trying to learn the Enterprise Library. I found this useful code sample to get data from a SQL database. But I tried to send data via a parameter. I'm also using the UPDATE, DELETE, and SAVE methods. Can you give me a similar sample? I'm using Enterprise Library 4.0.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace WebApplicationForEnterpirires
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Database objdbase = DatabaseFactory.CreateDatabase("connectionString");
            DataSet ds = objdbase.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetProducts");
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
    }
}
A: 

Have you tried this. This gives an example on how you can use the enterprise lib. to get DataSet passing a parameter.

ydobonmai
+2  A: 

You might find these handy http://msdn.microsoft.com/en-us/magazine/cc188705.aspx http://msdn.microsoft.com/en-us/magazine/cc188702.aspx

and this >>one<< which targets your situation directly (I think). Although I think what you want to do there, is pass the DbCommand object into your ExecuteDataSet method.

pms1969
A: 

First of all. Go to Microsoft download center for downloading Hand-on Labs. The Hand-on Labs has all you need in side (tutorial doc, sample code, exercise...etc). Just follow each steps with tutorial of every block. Then you could totally understand how to use the Enterprise Library in just few days.

Millionbonus