ADO.NET Provider for DB2

Build 24.0.9060

Tables

The Tables schema collection lists all tables in the database, including views.

Retrieving the Table Listing

To retrieve the Tables schema collection, call the GetSchema method of the DB2Connection class.

C#

String connectionString = "Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test";

using (DB2Connection conn = new DB2Connection(connectionString)) {
  conn.Open();
  DataTable databaseSchema = conn.GetSchema("Tables");
  foreach (DataRow row in databaseSchema.Rows) {
    Console.WriteLine(row["TABLE_NAME"]);
  }
}

VB.NET

Dim connectionString As String = "Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test"

Using conn As New DB2Connection(connectionString)
  conn.Open()
  Dim databaseSchema As DataTable = conn.GetSchema("Tables")
  For Each row As DataRow In databaseSchema.Rows
    Console.WriteLine(row("TABLE_NAME"))
  Next
End Using

Columns Returned

The Tables schema collection returns the following columns.

Column NameData TypeDescription
TABLE_CATALOGSystem.StringThe database that contains the table.
TABLE_SCHEMASystem.StringThe schema that contains the table.
TABLE_NAMESystem.StringThe table name.
TABLE_TYPESystem.StringThe table type.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060