Implementing OOP to Develop Database Oriented Applications using VB.NET 2005 (Page 1 of 6 )
This article explains how to implement object oriented programming to develop database oriented applications using VB.NET 2005. I took the simplest approach to develop this application.
A
downloadable zip file is available for this article.
I am dividing this tutorial into two parts. Part one, which is this article, contains the full source code for developing the application. Part two will contain the full explanation for the source code.
I have already contributed several articles on developing Data Access Layers, Object Oriented Database Development, implementing COM+, working with Enterprise Application Blocks, Windows Services, and so forth on this web site. If you are new to any of those, I suggest you go through my articles at http://www.aspfree.com/cp/bio/Jagadish-Chatarji.
In this article, I thought I would concentrate on OOP rather than data access. Since I have already contributed several articles covering best practices with data access, I don’t want to cover all of them again here. The source code that I developed for this tutorial is purposely made simple. Please note that there are better, even excellent, ways to handle databases from within your application.
Setting up the environment for this contribution
Before we begin, create a new Windows forms application, add an “app.config” file and modify the same in such a way that it looks something like the following:
< <?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
.
.
.
.
</system.diagnostics>
<connectionStrings>
<add name="SampleDB" connectionString="Data Source=.;initial catalog=sample;user id=sa"/>
</connectionStrings>
</configuration>
Since I wanted to demonstrate stored procedures which do not handle existing data in AdventureWorks, I created a table “emp” in a database called “sample,” with the following columns and data types:
- Empno (int)
- Ename (nvarchar(50))
- Sal (float)
- Deptno (int)
I pushed the following sample rows into that table:

Next: Developing a class which holds an entire row in a table >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee