Public Class Books Implements IDisposable 'Private members for internal usage Private SqlCommand As SqlClient.SqlDataAdapter Private QueryData As BookData Private CurrentRow As Int32 'Public New() interface for constructing the object Public Sub New() ... End Sub 'Public dispose interface Public Overridable Sub Dispose() Implements IDisposable.Dispose ... End Sub 'Protected dispose for internal class usage Protected Overridable Sub Dispose(ByVal disposing As Boolean) If Not disposing Then Exit Sub ' we're being collected, so let the GC take care of ' this object End If If Not SqlCommand Is Nothing Then If Not SqlCommand.SelectCommand Is Nothing Then If Not SqlCommand.SelectCommand.Connection Is Nothing Then SqlCommand.SelectCommand.Connection.Dispose() End If SqlCommand.SelectCommand.Dispose() End If SqlCommand.Dispose() SqlCommand = Nothing End If End Sub 'Public Query method provides the user of the object a method to 'start the query of the books in the database Public Sub Query() ... End Sub 'The public Fetch method provides the object user a method 'of fetching each record that was returned from the query 'The results are loaded into members for access via public properties Public Function Fetch() As Boolean ... End Function #Region " Property Definitions " Private strTitle As String Private strAuthor As String Private dPrice As Double Public ReadOnly Property Title() As String Get Title = strTitle End Get End Property Public ReadOnly Property Author() As String Get Author = strAuthor End Get End Property Public ReadOnly Property Price() As String Get Price = dPrice.ToString("c") End Get End Property #End Region 'The BookData class provides a DataSet that represents the data 'returned from the query Private Class BookData Inherits DataSet Public Const BOOK_TABLE As String = "TitleView" Public Const TITLE_COLUMN As String = "title" Public Const AUTHOR_COLUMN As String = "au_lname" Public Const PRICE_COLUMN As String = "price" Public Sub New(ByVal info As SerializationInfo, _ ByVal context As StreamingContext) MyBase.New(info, context) End Sub Public Sub New() MyBase.New() BuildDataTables() End Sub Private Sub BuildDataTables() ' ' Create the Books table ' Dim table As DataTable = New DataTable(BOOK_TABLE) With table.Columns .Add(TITLE_COLUMN, GetType(String)) .Add(AUTHOR_COLUMN, GetType(String)) .Add(PRICE_COLUMN, GetType(Double)) End With Me.Tables.Add(table) End Sub End Class End Class