Using the Microsoft Data Access Application Block

Application Blocks are a collection of libraries from Microsoft. Among the list of components will be the Data Access Application Block. This component can help to save considerable time by allowing you to specify several parameters and definitely will meet most if not all of your data access logic needs.

The download is here – Simply add the DLL to the BIN folder of your application or website. 

The main class for data access is the SqlHelper class. The SqlHelper class simplifies the job of writing data access


A data table can be created with a single line of code. Here’s an example.

Dim dt as System.Data.DataTable = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(Conn, System.Data.CommandType.Text, “select * from Products”).Tables(0)

Where Conn is the connection string to the database. Stored procedures can also be called by using CommandType.StoredProcedure. Parameters can be added an array of SqlParameter objects

Dim dt as System.Data.DataTable = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(Conn(), System.Data.CommandType.Text, “select * from Products where Field1=@Field1”, New System.Data.SqlClient.SqlParameter("@Field1", Field1)).Tables(0)

Methods are also available for DataReaders, XmlReaders, scalar values and non-queries. Here are some examples.

Dim dr As System.Data.SqlClient.SqlDataReader = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(Conn, CommandType.Text, "select * from Products")
Dim x As Integer = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(Conn, CommandType.Text, "select top 1 ProductID from Products")
SqlHelper.ExecuteNonQuery(Conn, CommandType.Text, "select from Products where ID=1")
Updated: March 6, 2015 — 4:56 pm


Add a Comment
  1. Your comment is awaiting moderation.

    You suggested this perfectly!
    ansia da prestazione cialis o viagra
    cialis 20mg
    cialis bei prostatabeschwerden
    cialis generic

  2. Your comment is awaiting moderation.

  3. Your comment is awaiting moderation.

    Seriously many of beneficial information.
    cialis kainos buy cialis online difference between generic cialis and brand cialis cialis 20 mg
    tumore prostata e cialis
    cialis biljni sastav
    cialis suggested dosage
    cialis clinical trials
    cialis and imdur
    cialis kaufen wo

Leave a Reply

Your email address will not be published. Required fields are marked *