Visual Basic.NET
  Home arrow Visual Basic.NET arrow Using Constructors with Object Oriented Da...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Using Constructors with Object Oriented Database Development with VB.NET 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2006-08-02

    Table of Contents:
  • Using Constructors with Object Oriented Database Development with VB.NET 2005
  • Defining constructors with parameters in a class
  • Constructor overloading within a class
  • The complete source code for working with the config file
  • Developing a simple Data Helper

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Using Constructors with Object Oriented Database Development with VB.NET 2005
    (Page 1 of 5 )

    This is the fourth article in a series on developing object oriented database applications using Visual Basic.NET 2005. In this article, I shall deal with the concept of “constructors.”
    A downloadable file for this article is available here.

    For this article, I assume that you understand enough of the basics of working with VB.NET controls, ADO.NET and so forth using Visual Basic.NET 2005. Even though this article only gives you the basics of OOP together with database development, I shall extend it in the form of a series to cover the most advanced topics in Visual Basic.NET 2005.  If you are very new to OOP in VB.NET, I request that you go through my first article in this series.

    The entire source code for this article is available in the form of a downloadable zip.  The solution was developed using Microsoft Visual Studio 2005 Professional Edition with Microsoft SQL Server 2005 Developer Edition on Microsoft Windows Server 2003 Enterprise Edition. Even though I believe that the source code available with this contribution can work with Microsoft Visual Studio.NET 2003/2002, I didn't really test it in any other environment. I request that you post in the discussion area if you have any problems in execution.

    To make this article simple, I created a sample database named "sample," with a table "emp" containing the columns empno (string), ename (string), sal (double) and deptno (integer) and a few rows.

    Defining constructors in a class

    I already introduced fields/methods/properties in my previous articles. Now, we are about to deal with a new concept called "constructors." A constructor is a special type of method that has the name "new." A constructor is executed automatically when an object of the respective class is created.

    Let us go through the following code:

    Public Class Emp

        Private m_empno As String
        Private m_ename As String
        Private m_sal As Double
        Private m_deptno As Integer
        Private m_errMsg As String

        Public Sub New()
            m_empno = ""
            m_ename = ""
            m_sal = 0
            m_deptno = 0
            m_errMsg = ""
        End Sub
        ...
    End Class

    The above class contains a method named "New," which is called a constructor. It is automatically executed for every object created from that class. A constructor generally contains all the statements necessary for initialization.  In this scenario, it may not be essential. 

    Some developers use constructors to read connection strings from XML files.  Some use them to open files or streams.  It all depends on the needs of the application.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys. Now it is the time for constructors in OO DB development with vb.net...
     

    VISUAL BASIC.NET ARTICLES

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway