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.
Try
AccountNumberComboBox.Items.Clear()
If TableNameComboBox.Text.Trim.Length > 0 Then
UniConnection.ConnectionString = ConnectionStringTextBox.Text
UniConnection.Open()
' 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))
Next
Next
End If
Catch ex As Devart.Data.Universal.UniException
MessageBox.Show(ex.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
UniConnection.Close()
End Try
Retrieving Metadata
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
Re: Retrieving Metadata
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 http://www.devart.com/dotconnect/oracle ... #getschemacojegede wrote:myDataTable = UniConnection.GetSchema("Columns", restrictions)
However, for the internal SQL Server provider you can use four restrictions for the "Columns" collection. For more information, please refer to http://msdn.microsoft.com/en-us/library ... 10%29.aspx
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" })
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" });
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.