Creating a Data Tier in ASP.NET
Every application starts with an idea, a thought or a need of some kind and the software of course becomes the solution. Once requirements have been gathered and the project vision is established the architects usually begin designing a logical framework for the application based on several factors.
It’s usually recommended no matter what the size or projected complexity of the application that there is some form of separation between interface logic, business rules and database logic. Creating this separation not only maintains a clean easier to read application but it also creates physically separate components which can then be reused in other areas or even deployed separately on other dedicated servers and invoked remotely.
A middle of the road approach is what most mid-sized applications will implement. Where most of the business logic will remain tied into the front end code and the database logic separated into another component and invoked as needed from the front end. This is still a 2-tier approach but it is definitely more favourable than having the database logic and SQL code embedded into the front end.
In this tutorial will we look at a fairly basic example of how to implement a database connection layer into an ASP.NET project which can then be invoked from your aspx pages in the code-behind. This style of approach bypasses all GUI wizards and connection/adapter controls which would normally be configured on the code-behind file. Instead we will push this logic into a separate component.
Note: Part 1 requires Visual Studio .NET running ASP.NET ver 1.1 and access to any version of SQL server. Both VB.NET and C# code samples will be provided
Important Note! This tutorial will ‘not’ demonstrate how to actually execute the database requests or link to a sample database. This tutorial provides the class required to create a proper database layer which you can then implement into your own applications on any SQL database of your choice. Reading samples tables or executing stored procedures for example are not demonstrated in this tutorial.