Click here to Skip to main content
11,494,851 members (60,807 online)
Click here to Skip to main content

Create a Business Logic Layer, Data Access Layer classes, and Stored Procedure scripts from a database table

, 4 Jun 2010 CPOL 105.2K 8K 82
Rate this:
Please Sign up or sign in to vote.
Create a Business Logic Layer, Data Access Layer classes, and Stored Procedure scripts from a database table.

Introduction

One of the most tedious parts of developing database-driven applications is coding the classes for your database objects. Especially in a situation when you are dealing with a database containing a large number of tables, or tables with many columns. Today, the application development process has vastly expanded so it is better to use sub applications to generate code dynamically / automatically. I developed this application to reduce burden on software developers and provide them some relief. As a software developer, I can understand very well that programming is a tough job so they need some rest.

Key features

The application is designed to create:

  1. Business Logic Layer class
  2. Data Access Layer class
  3. SQL Database Stored Procedure script

Key benefits

  1. Reduce development time.
  2. Reduce development cost.
  3. Follow standard coding techniques and application architecture.
  4. Fully commented code so any one can easily modify it according to their needs.

How to use this application

In order to use this application, you must know the computer name/ IP address and the login information for connecting to a SQL Server database.

NotConnected.JPG

After successful login, you can go to another tab "Create Class and Stored Procedure". Select a particular database and check the tables to create the Stored Procedure and classes. Click on the Create button to create Stored Procedures and classes.

All classes and Stored Procedure scripts reside in the bin folder.

Connected.JPG

Example

As a very simple example, suppose we have the table name Employee.

DBTable.JPG

Create Business Logic Layer class

The Business Logic Layer class contains the namespaces, default constructor, private fields, and public properties with getters and setters and all the methods (Select, Insert, Delete, and Update) required for connecting the Database Access Layer. For every database table, it creates a class with the same name as the table name and concatenates it with controller. This example application will create a class with the name clsEmployeeController. It also creates properties with the name same as the table attributes.

BusinessLayer.JPG

Create Data Access Layer class

The Database Access Layer class contains the namespaces, default constructor, private fields, and public properties with getters and setters and all the methods (Select, Insert, Delete, and Update) required to directly deal with a database with Stored Procedures. For every database table, it creates a class with the same name as the table name and creates the properties with the same name as the table attributes. In this example, the application will create a class with the name clsEmployee.

DataBaseLayer.JPG

Create Stored Procedure script

It also creates a script of four Stored Procedures (Select, Insert, Delete, Update) in a Notepad file with the same name as the table name. You can simply copy and run it on the SQL Query Analyzer.

Points of Interest

I did not use any library in this application. It is a small application with big benefits.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Syeda Anila Nusrat
Software Developer
Pakistan Pakistan
Name: Syeda Anila Nusrat

Education:-
National University of Computer and Emerging Sciences
MS (Computer Science) 2010–2012
Federal Urdu University of Arts, Science and Technology
BS (Computer Science) 2004–2007

Professional Experience:-
Software Engineer at Systems Pvt Ltd (Nov 2010-Mar 2011)
Software Engineer at Syndustria Pvt Ltd (Jun2008-Feb2010)
Software Engineer(internee) at yEvolve Pvt Ltd (Feb2008-Apr 2008)

Specialties:-
IDE: Ms Visual Studio 2005 and 2008
Programming Languages: C++.NET, C#.NET, VB.NET, ADO.NET
Web Technologies: ASP.NET, AJAX, Html, CSS, Java Scripting
Databases: SQL Server 2000, SQL Server 2005
Programming Methodologies: Multithreading and DLLs
Scheduling and Modeling tools: Ms-Project 2000, MS Visio, Rational Rose

Honors and Awards:-
Received Merit Certificate for scoring 3.81 CGPA on scale of 4.0 in BS(CS)

My professional Network
http://pk.linkedin.com/in/syedaanila

Comments and Discussions

 
GeneralFeedBack Pin
Rizwan ali16-Apr-15 0:25
memberRizwan ali16-Apr-15 0:25 
SuggestionFeedback Pin
Jawad Shairf16-Feb-15 0:23
professionalJawad Shairf16-Feb-15 0:23 
QuestionHow to get this application....? Pin
Member 1084098014-Feb-15 22:15
memberMember 1084098014-Feb-15 22:15 
QuestionWhat does mean "Transaction"? Please help... Pin
Tavbi16-Jul-14 10:29
memberTavbi16-Jul-14 10:29 
QuestionVariable and Properties Writting Pin
Shafiqur Rahman, Banladesh24-Jun-14 4:44
memberShafiqur Rahman, Banladesh24-Jun-14 4:44 
QuestionGreat JOb! Pin
rajeshmoorthy17-Feb-14 18:02
memberrajeshmoorthy17-Feb-14 18:02 
QuestionWhere does it create the class? Pin
Ahmed Alaa El-Din19-Dec-13 10:35
memberAhmed Alaa El-Din19-Dec-13 10:35 
QuestionComment Pin
Vicky19313-Jun-13 19:34
memberVicky19313-Jun-13 19:34 
QuestionMicrosoft.ApplicationBlocks.Data Pin
Member 223132123-Aug-12 0:49
memberMember 223132123-Aug-12 0:49 
AnswerRe: Microsoft.ApplicationBlocks.Data Pin
aurinai17-Dec-12 7:15
memberaurinai17-Dec-12 7:15 
QuestionAny chance for a VB.NET version? Pin
GroBeMaus10-Apr-12 11:42
memberGroBeMaus10-Apr-12 11:42 
QuestionWhy are there two classes for each table? Pin
OpethManiac12-Jan-12 5:53
memberOpethManiac12-Jan-12 5:53 
AnswerRe: Why are there two classes for each table? Pin
GroBeMaus11-Apr-12 5:09
memberGroBeMaus11-Apr-12 5:09 
The "cls" is his notation for "class" I just use "c" that way anything you see with "cls" in the name you will know is a class. The reason for the two classes is that he is separating the business logic from the data access logic. You use the controller class (business logic), the controller class uses the entity class to do the work (data logic)...more or less.
GeneralMy vote of 4 Pin
vanita tripathi17-Nov-11 20:35
membervanita tripathi17-Nov-11 20:35 
GeneralMy vote of 5 Pin
Mahesh Gholap3-Jun-11 22:44
memberMahesh Gholap3-Jun-11 22:44 
General[My vote of 1] Please tell me you used CodeDom Pin
Argyle4Ever4-Jun-10 6:31
memberArgyle4Ever4-Jun-10 6:31 
GeneralRe: [My vote of 1] Please tell me you used CodeDom Pin
Syeda Anila Nusrat4-Jun-10 9:07
memberSyeda Anila Nusrat4-Jun-10 9:07 
GeneralRe: [My vote of 1] Please tell me you used CodeDom Pin
Argyle4Ever4-Jun-10 10:35
memberArgyle4Ever4-Jun-10 10:35 
GeneralRe: [My vote of 1] Please tell me you used CodeDom Pin
josto221-Jul-10 7:35
memberjosto221-Jul-10 7:35 
Generalcombine with asp.net MVC Pin
zhuqil3-Jun-10 20:40
memberzhuqil3-Jun-10 20:40 
GeneralCode generation error [modified] Pin
ipadilla3-Jun-10 11:32
memberipadilla3-Jun-10 11:32 
GeneralRe: Code generation error Pin
Syeda Anila Nusrat3-Jun-10 15:44
memberSyeda Anila Nusrat3-Jun-10 15:44 
GeneralRe: Code generation error Pin
ipadilla3-Jun-10 21:40
memberipadilla3-Jun-10 21:40 
GeneralRe: Code generation error Pin
Syeda Anila Nusrat3-Jun-10 22:47
memberSyeda Anila Nusrat3-Jun-10 22:47 
GeneralRe: Code generation error [modified] Pin
ipadilla3-Jun-10 23:57
memberipadilla3-Jun-10 23:57 
GeneralRe: Code generation error Pin
Syeda Anila Nusrat4-Jun-10 5:31
memberSyeda Anila Nusrat4-Jun-10 5:31 
GeneralRe: Code generation error [modified] Pin
ipadilla4-Jun-10 7:20
memberipadilla4-Jun-10 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 4 Jun 2010
Article Copyright 2010 by Syeda Anila Nusrat
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid