Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » Databases » Downloads
 
Add your own
alternative version

Object-Oriented database design with the DatabaseObjects library

, 31 Jan 2007
Demonstrates creating object-oriented database systems with the DatabaseObjects library.
databaseobjects_demo_net.zip
VB.NET
demo
source
Northwind
NorthwindDB
bin
Northwind.vbproj.user
AxInterop.SHDocVw.dll
DatabaseObjects.dll
Interop.SHDocVw.dll
Northwind.exe
NorthwindDatabase.dll
NorthwindDatabase.vbproj.user
Attributes
bin
Database
DatabaseObjects.vbproj.user
Misc
SQL
DatabaseObjects.dll
Data
mysql_northwind.zip
Documentation
DatabaseObjects.chm
databaseobjects_demo_vb6.zip
VB6
demo
regsvr32.exe
source
Northwind
Northwind.vbg
NorthwindDB
ControlAnchor.cls
frmMain.frm
frmMain.frx
frmOrder.frm
frmOrder.frx
frmProducts.frm
frmProducts.frx
frmProductSearch.frm
frmProductSearch.frx
frmProductSearchExtended.frm
frmProductSearchExtended.frx
frmSuppliers.frm
frmSuppliers.frx
Northwind.exe
northwind.RES
Northwind.vbp
Categories.cls
Category.cls
Data.bas
LateBoundObject.cls
NorthwindDatabase.cls
NorthwindDatabase.OBJ
NorthwindDB.dll
NorthwindDB.vbp
Order.cls
OrderDetail.cls
OrderDetails.cls
Orders.cls
Product.cls
Products.cls
ProductSearch.cls
Supplier.cls
Suppliers.cls
bin
Database.cls
DBO.vbp
GlobalDatabase.cls
GlobalDatabaseObjects.cls
IDatabaseObject.cls
IDatabaseObjects.cls
IGlobalDatabaseObjects.cls
ISQLStatement.cls
modMisc.bas
SQLAlterTable.cls
SQLAutoIncrementValue.cls
SQLCondition.cls
SQLConditionFieldCompare.cls
SQLConditionInSelect.cls
SQLConditions.cls
SQLConditionSelect.cls
SQLCreateIndex.cls
SQLCreateTable.cls
SQLDelete.cls
SQLDropIndex.cls
SQLDropTable.cls
SQLFieldValue.cls
SQLFieldValues.cls
SQLIndexExists.cls
SQLIndexField.cls
SQLIndexFields.cls
SQLInsert.cls
SQLSelect.cls
SQLSelectField.cls
SQLSelectFields.cls
SQLSelectGroupByField.cls
SQLSelectGroupByFields.cls
SQLSelectOrderByField.cls
SQLSelectOrderByFields.cls
SQLSelectTable.cls
SQLSelectTableJoin.cls
SQLSelectTableJoinCondition.cls
SQLSelectTableJoinConditions.cls
SQLSelectTableJoins.cls
SQLSelectTables.cls
SQLTableExists.cls
SQLTableField.cls
SQLTableFields.cls
SQLUpdate.cls
SQLUpdateCopyField.cls
SQLUpdateCopyFields.cls
DatabaseObjects_vb6.dll
mysql_northwind.zip
images
templates
databaseobjects_classdiagram.jpg
logo.jpg
databaseobjects_src_net.zip
DatabaseObjects.vbproj.user
DatabaseObjects.dll
databaseobjects_src_vb6.zip
Database.cls
DBO.vbp
GlobalDatabase.cls
GlobalDatabaseObjects.cls
IDatabaseObject.cls
IDatabaseObjects.cls
IGlobalDatabaseObjects.cls
ISQLStatement.cls
modMisc.bas
SQLAlterTable.cls
SQLAutoIncrementValue.cls
SQLCondition.cls
SQLConditionFieldCompare.cls
SQLConditionInSelect.cls
SQLConditions.cls
SQLConditionSelect.cls
SQLCreateIndex.cls
SQLCreateTable.cls
SQLDelete.cls
SQLDropIndex.cls
SQLDropTable.cls
SQLFieldValue.cls
SQLFieldValues.cls
SQLIndexExists.cls
SQLIndexField.cls
SQLIndexFields.cls
SQLInsert.cls
SQLSelect.cls
SQLSelectField.cls
SQLSelectFields.cls
SQLSelectGroupByField.cls
SQLSelectGroupByFields.cls
SQLSelectOrderByField.cls
SQLSelectOrderByFields.cls
SQLSelectTable.cls
SQLSelectTableJoin.cls
SQLSelectTableJoinCondition.cls
SQLSelectTableJoinConditions.cls
SQLSelectTableJoins.cls
SQLSelectTables.cls
SQLTableExists.cls
SQLTableField.cls
SQLTableFields.cls
SQLUpdate.cls
SQLUpdateCopyField.cls
SQLUpdateCopyFields.cls
DatabaseObjects_vb6.dll
Option Strict Off
Option Explicit On 

Imports NorthwindDatabase
Imports System.Windows.Forms

Friend Class frmSuppliers
    Inherits System.Windows.Forms.Form

#Region "Windows Form Designer generated code "
	Public Sub New()
		MyBase.New()
        'This call is required by the Windows Form Designer.
		InitializeComponent()
	End Sub
	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer
	Public ToolTip1 As System.Windows.Forms.ToolTip
	Public WithEvents cmdDelete As System.Windows.Forms.Button
	Public WithEvents cmdNew As System.Windows.Forms.Button
	Public WithEvents cmdRename As System.Windows.Forms.Button
	Public WithEvents cmdClose As System.Windows.Forms.Button
	Public WithEvents lstSuppliers As System.Windows.Forms.ListBox
	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.cmdDelete = New System.Windows.Forms.Button
        Me.cmdNew = New System.Windows.Forms.Button
        Me.cmdRename = New System.Windows.Forms.Button
        Me.cmdClose = New System.Windows.Forms.Button
        Me.lstSuppliers = New System.Windows.Forms.ListBox
        Me.SuspendLayout()
        '
        'cmdDelete
        '
        Me.cmdDelete.BackColor = System.Drawing.SystemColors.Control
        Me.cmdDelete.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdDelete.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdDelete.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdDelete.Location = New System.Drawing.Point(188, 404)
        Me.cmdDelete.Name = "cmdDelete"
        Me.cmdDelete.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdDelete.Size = New System.Drawing.Size(81, 24)
        Me.cmdDelete.TabIndex = 3
        Me.cmdDelete.Text = "Delete"
        '
        'cmdNew
        '
        Me.cmdNew.BackColor = System.Drawing.SystemColors.Control
        Me.cmdNew.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdNew.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdNew.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdNew.Location = New System.Drawing.Point(12, 404)
        Me.cmdNew.Name = "cmdNew"
        Me.cmdNew.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdNew.Size = New System.Drawing.Size(81, 24)
        Me.cmdNew.TabIndex = 1
        Me.cmdNew.Text = "&New"
        '
        'cmdRename
        '
        Me.cmdRename.BackColor = System.Drawing.SystemColors.Control
        Me.cmdRename.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdRename.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRename.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdRename.Location = New System.Drawing.Point(100, 404)
        Me.cmdRename.Name = "cmdRename"
        Me.cmdRename.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdRename.Size = New System.Drawing.Size(81, 24)
        Me.cmdRename.TabIndex = 2
        Me.cmdRename.Text = "&Rename"
        '
        'cmdClose
        '
        Me.cmdClose.BackColor = System.Drawing.SystemColors.Control
        Me.cmdClose.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.cmdClose.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdClose.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdClose.Location = New System.Drawing.Point(328, 404)
        Me.cmdClose.Name = "cmdClose"
        Me.cmdClose.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdClose.Size = New System.Drawing.Size(81, 24)
        Me.cmdClose.TabIndex = 4
        Me.cmdClose.Text = "&Close"
        '
        'lstSuppliers
        '
        Me.lstSuppliers.BackColor = System.Drawing.SystemColors.Window
        Me.lstSuppliers.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstSuppliers.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lstSuppliers.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstSuppliers.ItemHeight = 14
        Me.lstSuppliers.Location = New System.Drawing.Point(12, 12)
        Me.lstSuppliers.Name = "lstSuppliers"
        Me.lstSuppliers.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstSuppliers.Size = New System.Drawing.Size(397, 382)
        Me.lstSuppliers.TabIndex = 0
        '
        'frmSuppliers
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.CancelButton = Me.cmdClose
        Me.ClientSize = New System.Drawing.Size(420, 435)
        Me.Controls.Add(Me.cmdDelete)
        Me.Controls.Add(Me.cmdNew)
        Me.Controls.Add(Me.cmdRename)
        Me.Controls.Add(Me.cmdClose)
        Me.Controls.Add(Me.lstSuppliers)
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Location = New System.Drawing.Point(3, 29)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmSuppliers"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "Suppliers"
        Me.ResumeLayout(False)

    End Sub
#End Region 

	Private Sub LoadSuppliers()
		
        Dim objSupplier As Supplier
		
		With Me.lstSuppliers
			.Items.Clear()
			
            'To use the For Each enumerator see the GetEnumerator function in the Suppliers class
            For Each objSupplier In NorthwindDB.Suppliers
                .Items.Add(objSupplier.Name)
            Next

            ''Alternatively you can interate using the ObjectByOrdinal
            'Dim intIndex As Integer
            'For intIndex = 0 To NorthwindDB.Suppliers.Count - 1
            '    .Items.Add(NorthwindDB.Suppliers(intIndex).Name)
            'Next

        End With
		
	End Sub
	
	Private Sub cmdNew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNew.Click
		
        Dim objSupplier As Supplier
		Dim strNewSupplierName As String
		
        strNewSupplierName = InputDialog.InputBox("Please enter the name of the new supplier:", "", "")
		
        If strNewSupplierName <> Nothing Then
            If NorthwindDB.Suppliers.Exists(strNewSupplierName) Then
                MessageBox.Show("Supplier '" & strNewSupplierName & "' already exists.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                objSupplier = New Supplier
                objSupplier.Name = strNewSupplierName
                objSupplier.Save()
                LoadSuppliers()
            End If
        End If
		
	End Sub
	
	Private Sub cmdRename_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRename.Click
		
		Dim strNewSupplierName As String
        Dim objSupplier As Supplier
		
		If Me.lstSuppliers.SelectedIndex >= 0 Then
            objSupplier = NorthwindDB.Suppliers(Me.lstSuppliers.Text)
            strNewSupplierName = InputDialog.InputBox("Please enter the new supplier name for '" & objSupplier.Name & "'.", "", objSupplier.Name).Trim
            If strNewSupplierName <> Nothing Then
                'if the new name is the same as the old name then do nothing
                If String.Compare(strNewSupplierName, objSupplier.Name, ignorecase:=True) = 0 Then

                ElseIf NorthwindDB.Suppliers.Exists(strNewSupplierName) Then
                    MessageBox.Show("This supplier name already exists.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Else
                    objSupplier.Name = strNewSupplierName
                    objSupplier.Save()
                    LoadSuppliers()
                End If
            End If
        Else
            MessageBox.Show("Please select a supplier to rename.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
		End If
		
	End Sub
	
	Private Sub cmdDelete_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDelete.Click
		
        Dim objSupplier As Supplier
		
		If Me.lstSuppliers.SelectedIndex >= 0 Then
            objSupplier = NorthwindDB.Suppliers(Me.lstSuppliers.Text)
			If objSupplier.IsDeletable Then
                If MessageBox.Show("Are you sure you want to delete supplier '" & objSupplier.Name & "'.", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                    NorthwindDB.Suppliers.Delete(objSupplier)
                    LoadSuppliers()
                End If
            Else
                MessageBox.Show("Supplier '" & objSupplier.Name & "' cannot be deleted, because it is a supplier of an existing product.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
			End If
		Else
            MessageBox.Show("Please select a supplier to delete.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
		End If
		
	End Sub
	
	Private Sub frmSuppliers_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		
		LoadSuppliers()
		
	End Sub
	
	Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
		
		Me.Close()
		
	End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Toby Wicks

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150129.1 | Last Updated 31 Jan 2007
Article Copyright 2005 by Toby Wicks
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid