Download here.
This guide discusses the design and implementation in detail and describes the various web and worker roles that comprise the Surveys application.
VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
This sample code snippet gives you a kick start (Hello World
) on Microsoft Patterns & Practices Enterprise Library – Data Access Application Block.
Remember that there a more than one way to do most steps. I am not going to confuse you by writing all.
- First you need to download and install Enterprise Library. I used version 4.1 which is the latest at the time of writing this entry.
- Create a new project. I used a C# Windows application on my Visual Studio 2008 Express.
- Now you need to add reference to dlls
- Microsoft.Practices.EnterpriseLibrary.Common and
- Microsoft.Practices.EnterpriseLibrary.Data
- Below code does the following:
- Create database connection. I used a SQL Server 2008 Database.
- Execute a SELECT statement
- Populates data to a DataGridView control
using System;
using System.Windows.Forms;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string strCon = @"Database=test;Server=localhost;
Integrated Security=SSPI";
SqlDatabase db = new SqlDatabase(strCon);
DbCommand cmd = db.GetSqlStringCommand("SELECT *FROM test");
DataSet ds = db.ExecuteDataSet(cmd);
dataGridView1.DataSource = ds.Tables[0];
}
}
}
VN:F [1.9.18_1163]
Rating: 5.0/5 (2 votes cast)
Recent Comments