Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Implementing OOP to Develop Database Orien...
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

Implementing OOP to Develop Database Oriented Applications using VB.NET 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 24
    2007-01-22

    Table of Contents:
  • Implementing OOP to Develop Database Oriented Applications using VB.NET 2005
  • Developing a class which holds an entire row in a table
  • Developing a class which holds a set of rows belonging to the same table
  • Developing a factory class to update rows to the database
  • Developing a class to interact with databases
  • Developing the application

  • 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

    Ajax Application Generator Generate database 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!

    Implementing OOP to Develop Database Oriented Applications using VB.NET 2005 - Developing a factory class to update rows to the database
    (Page 4 of 6 )

    Once we are provided with every object, we need to update them in the database whenever necessary. The following is the class which tries to save the object in the database as needed:

    PublicClass EmployeeFactory

        Inherits Employee

        Public Sub New()

        End Sub

        Public Sub New(ByVal e As Employee)

            MyBase.New(e)

        End Sub

        Public Sub add()

            DBHelper.SQLExecute("insert into emp(empno,ename,sal,deptno) values (" & Empno & ",'" & Ename & "'," & Sal & "," & Deptno & ")")

        End Sub

        Public Sub add(ByVal e As Employee)

            Empno = e.Empno

            Ename = e.Ename

            Sal = e.Sal

            Deptno = e.Deptno

            add()

        End Sub

        Public Sub update()

            DBHelper.SQLExecute("update emp set ename='" & Ename & "',sal=" & Sal & ",deptno=" & Deptno & " where empno=" & Empno)

        End Sub

        Public Sub update(ByVal e As Employee)

            Empno = e.Empno

            Ename = e.Ename

            Sal = e.Sal

            Deptno = e.Deptno

            update()

        End Sub

        Public Sub delete()

            DBHelper.SQLExecute("delete from emp where empno=" & Empno)

        End Sub

        Public Sub delete(ByVal empno As Integer)

            Me.Empno = empno

            delete()

        End Sub

        Public Function getEmployee(ByVal empno As Integer) As Employee

            Dim dr As DataRow = DBHelper.getRow("select * from emp where empno=" & empno)

            empno = dr("empno")

            Ename = dr("ename")

            Sal = dr("sal")

            Deptno = dr("deptno")

            Return CType(Me, Employee)

        End Function

        Public Shared Function getList() As Employees

            Dim dt As DataTable = DBHelper.getDataTable("select * from emp")

            Dim colEmp As New Employees

            For Each dr As DataRow In dt.Rows

                colEmp.add(New Employee(dr("empno"), dr("ename"), dr("sal"), dr("deptno")))

            Next

            Return colEmp

        End Function

    EndClass

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · This is a simple introduction to developer OOP based database applications using...
       · Excellent article. Jag is a great teacher.keep up the good work
     

    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 1 hosted by Hostway