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();
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With