Retrieving Metadata

Retrieving Metadata

Postby cojegede » Mon 10 Nov 2014 13:21

I am using dotconnect universal trial version and I am using your sample code that I found in the help. When I run it myDataTable.Rows return 0. I don't know what to do.

If TableNameComboBox.Text.Trim.Length > 0 Then
UniConnection.ConnectionString = ConnectionStringTextBox.Text

' Dim restrictions() As String = {"Test", TableNameComboBox.Text}
restrictions = {TableNameComboBox.Text}
myDataTable = UniConnection.GetSchema("Columns", restrictions)
Dim i As Int32
Dim myRow As DataRow
Dim myCol As DataColumn
For Each myRow In myDataTable.Rows
For Each myCol In myDataTable.Columns
Console.Write(myRow(myCol) & Chr(9))
End If
Catch ex As Devart.Data.Universal.UniException
Catch ex As Exception
End Try
Posts: 2
Joined: Mon 10 Nov 2014 12:47

Re: Retrieving Metadata

Postby Pinturiccio » Thu 13 Nov 2014 17:12

cojegede wrote:myDataTable = UniConnection.GetSchema("Columns", restrictions)

Every internal provider has its own rules for using the GetSchema method. For example, if you use the internal Oracle provider (dotConnect for Oracle), there are three restrictions for the "Columns" collection. For more information, please refer to

However, for the internal SQL Server provider you can use four restrictions for the "Columns" collection. For more information, please refer to

If you specify incorrect information in your restrictions variable, you will get zero rows.

Use the following code for Oracle:
Code: Select all
myDataTable = UniConnection.GetSchema("Columns", New String() {"SCOTT", "DEPT" })

Where SCOTT is the schema name and DEPT is the table name. You can also add the third restriction - the name of the specific column.

Please note that if object names were not quoted, Oracle capitalizes all the object names when creating objects. You should specify the schema and table name in uppercase. If the name case in the code differs from the name case in the database, zero rows are returned.

Use the following code for SQL Server:

Code: Select all
DataTable myDataTable = conn.GetSchema("Columns", New String() { "Master", "dbo", "dept" });

Where Master is the catalog name, dbo is the owner name, and dept is the table name. You can also add the fourth restriction - the name of the specific column.
Unlike Oracle, you don't need to use the correct case for SQL Server - you can specify the name in any case.

If you use other providers in UniConnection, please find out how the GetSchema method of these providers works.
Devart Team
Posts: 1983
Joined: Wed 02 Nov 2011 09:44

Return to dotConnect Universal