Sunday, November 26, 2006

.Net Layered Design (Automated) with LLBL Gen. Pro.

Exploring LLBL Gen. Pro.

Want to know what is LLBL Gen. Pro. ??? than click here.

Using LLBL Gen. Pro. tool is divided into Three parts
Part 1: Discuss All about Generating Files from LLBL Tool.
Part 2: Execute StoredProcedure in Database.
Part 3: Discussion about using files generated from LLBL Tool.

Part1
Step1: Enter DB Server., user-id and password.


Step2: Select Table.


Step3: Select Language option and namespace. Select DBNull value support and property option rather than web.config file option.


Step4: Select the field names


Step5: Start Generation : It will generate three files clsCustomer.cs, clsDBInteractionBase.cs and Northwind_LLBL_StoredProcedures.txt

clsCustomer.cs - It consist of functions for SelectOne, SelectAll, Update, Delete, Insert, Update.

clsDBInteractionBase.cs - It is a abstract class which needs to be included once for all the tables, it consist of functions such as BeginTransaction, CommitTransaction, RollbackTransaction, and so on which are require for DBInteraction.

Northwind_LLBL_StoredProcedures.txt - It consist of stored procedure to be executed on database.


Part2
Step1: Open QueryAnalyzer, and select the database. (here choose Northwind).

Step2: Copy all the content from "Northwind_LLBL_StoredProcedures" file and execute it in query analyser.


Part3
Step1: Create New Web Project (you can use it with window project, but for this example i am going to explain with Web Project).

Step2: Add New Class Library project. (you can make individual class library project outside main project and add its .dll file as reference)




Step3: Add Files to Class Library Project.
Files to be add as existing items are:
- clsCustomer.cs and
- clsDBInteractionBase.cs (Note: clsDBInteractionBase class needs to be added only 1 time for N no. of classes (associated with tables))

After Files are added.


Step4: Make changes in clsDBInteractionBase.cs file.
In InitClass() method, change m_ScoMainConnection.ConnectionString = ConfigurationSettings.AppSettings["connStr"].ToString();
where "connStr" is a key for connection string define in web.config file.
This change will help you to use connection string from web.config file.

Also, if required, In clsCustomer.cs file replace Int32 with SqlInt32.

Step5: Add the reference of class project within your web project to use its functionality. Right click on web project and click on add reference and add choose project tab., add the Northwind Class.

Step6: For testing the functionality take a datagrid on form.

Step7: Switch to Code view and add namespace of generated file.
eg: using NorthwindLLBL;

Step8: Add code to display all the data of customer in datagrid.
eg:
if(!Page.IsPostBack)
{
clsCustomers objCust = new clsCustomers();
DataGrid1.DataSource = objCust.SelectAll();
DataGrid1.DataBind();
}

That it, you are done with it, so now Depend on your need you can perform different operations as everything is ready for your use.

No comments:

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape