IDbTableManager..::.GetTables Method Home
.NET Framework Class Library
IDbTableManager..::.GetTables Method

Returns a list of tables from a database.

Namespace:  Microsoft.Web.Management.DatabaseManager
Assembly:  Microsoft.Web.Management.DatabaseManager (in Microsoft.Web.Management.DatabaseManager.dll)
Syntax

'Usage

Dim instance As IDbTableManager
Dim connectionString As String
Dim returnValue As ICollection(Of Table)

returnValue = instance.GetTables(connectionString)

'Declaration

Function GetTables ( _
    connectionString As String _
) As ICollection(Of Table)

Parameters

connectionString
Type: System..::.String
The connection string for the database.

Return Value

Type: System.Collections.Generic..::.ICollection<(Of <(Table>)>)
An ICollection object that contains the collection of Table objects.
Remarks

All database providers that implement the IDbTableManager interface must also implement the GetTables method, which the database manager will use to retrieve the list of tables for a database.

Examples

The following code sample implements the GetTables method to retrieve the list of tables for an OLEDB connection by using the connection string that the database manager provides.


    Public Function GetTables(ByVal connectionString As String) As System.Collections.Generic.ICollection(Of Table) Implements Microsoft.Web.Management.DatabaseManager.IDbTableManager.GetTables
        Dim tables As List(Of Table) = New List(Of Table)
        ' Create a connection to the database.
        Dim connection As OleDbConnection = New OleDbConnection(connectionString)
        ' Open the connection to the database.
        connection.Open()
        Dim restrictions() As String = New String((4) - 1) {}
        restrictions(3) = "TABLE"
        ' Open the schema information for the tables.
        Dim schema As DataTable = connection.GetSchema(OleDbMetaDataCollectionNames.Tables, restrictions)
        ' Enumerate the list of tables.
        For Each row As DataRow In schema.Rows
            ' Create a new table object.
            Dim table As Table = New Table
            ' Specify the table name.
            table.Name = CType(row("TABLE_NAME"), String)
            ' Test for a creation date.
            If Not DBNull.Value.Equals(row("DATE_CREATED")) Then
                ' Create a date/time object.
                Dim createDate As DateTime = New DateTime
                ' Parse the creation date for the table.
                If DateTime.TryParse(row("DATE_CREATED").ToString, createDate) Then
                    ' Specify the creation date for the table.
                    table.CreateDate = createDate
                End If
            End If
            ' Specify the table schema.
            If Not DBNull.Value.Equals(row("TABLE_SCHEMA")) Then
                table.Schema = CType(row("TABLE_SCHEMA"), String)
            Else
                table.Schema = String.Empty
            End If
            ' Add the table to the list of tables.
            tables.Add(table)
        Next
        ' Return the list of tables.
        Return tables

    End Function



Permissions

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View