.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

4 steps to use readymade DAL component (Data application blocks)

Posted By:Shivprasad koirala       Posted Date: January 22, 2009    Points: 25    Category: ASP.NET    URL: http://www.questpond.com  
 

4 steps to use readymade DAL component (Data application blocks)
 

 

Introduction
 

One of the most important components in a project is the DAL component. Many developers end up creating their own DAL component which is pretty time consuming. A Microsoft enterprise application block has a very decent and time tested DAL component i.e. the Enterprise data application blocks. This tutorial will run through the necessary steps of how you can use Enterprise data application blocks in your DAL component.

I have been writing and recording lot of architecture related videos on design patterns, UML , estimation and C# projects. You can see the sample videos at http://www.questpond.com/FreeDesign1.htm  .



Step1 :- Install enterprise application blocks from http://www.microsoft.com/downloads/details.aspx?FamilyId=90DE37E0-7B42-4044-99BE-F8ECFBBC5B65&displaylang=en 
Once you install the block open the enterprise library configuration screen.
 

Step2:- Open the project web.config file in which you want to reuse the data application block. Once you have opened the web.config file we need to provide ConnectionString as shown in the below figure.


Step 3:- Save the setting and then set the default database to the currently configure connection string. In this sample we have renamed the connection string to 'MyDatabase'. So we have selected the default database as 'MyDatabase'.
 

Step 4 :- Now that we done all the configuration we need to write the code to call the data application block. First step import the two important namespaces of enterprise library. In the second step use the databasefactory static class to create the database object. If you remember we had made the 'MyDataBase' as a default. So the factory uses the default connection string to create the database object.

In the third step pass the stored procedure which needs to be executed. If the stored procedure has input parameters you can use the overloaded method to pass the data. Currently we want to get the dataset to bind with the grid so we have called the 'ExecuteDataset' function. In the final step we have binded the same with data grid.
 

Nine lines of code compressed to three lines of code
 

Ok what have we achieved by this. Nine lines of code has become three lines of code.PRODUCTIVITY
 

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend