OleDbConnection.GetOleDbSchemaTable Method
Assembly: System.Data (in system.data.dll)
'Declaration Public Function GetOleDbSchemaTable ( _ schema As Guid, _ restrictions As Object() _ ) As DataTable 'Usage Dim instance As OleDbConnection Dim schema As Guid Dim restrictions As Object() Dim returnValue As DataTable returnValue = instance.GetOleDbSchemaTable(schema, restrictions)
public DataTable GetOleDbSchemaTable ( Guid schema, Object[] restrictions )
public function GetOleDbSchemaTable ( schema : Guid, restrictions : Object[] ) : DataTable
Parameters
- schema
One of the OleDbSchemaGuid values that specifies the schema table to return.
- restrictions
An Object array of restriction values. These are applied in the order of the restriction columns. That is, the first restriction value applies to the first restriction column, the second restriction value applies to the second restriction column, and so on.
Return Value
A DataTable that contains the requested schema information.| Exception type | Condition |
|---|---|
| The specified set of restrictions is invalid. | |
| The OleDbConnection is closed. | |
| The specified schema rowset is not supported by the OLE DB provider. -or- The schema parameter contains a value of DbInfoLiterals and the restrictions parameter contains one or more restrictions. |
The schema table is returned as a DataTable that has the same format as the OLE DB schema rowset specified by the schema parameter. Use the restrictions parameter to filter the rows to be returned in the DataTable (for example, by specifying restrictions for tablename, type, owner, or schema). When you pass values in the array, include empty strings or nulls for array elements that do not contain values. If you pass an empty array to restrictions, all rows (one for each table) are returned in default order. Values in the array correspond to the order of the columns in the source table and DataTable. Each element in the restrictions array is compared with the content of the corresponding column in the schema rowset. For example, the first element in the restrictions array is compared to first column in the rowset. If a restriction element is not null, only rows from the schema rowset that exactly match the value of the restriction are added to the resulting DataTable.
The OleDbConnection method calls the underlying OLE DB IDBSchemaRowset::GetRowset method using standard common language runtime conversion rules. For more information, see COM Data Types.
You can retrieve information about literals by using DbInfoLiterals. This provides information equivalent to calling the OLE DB IDBInfo::GetLiteralInfo interface, or the ADO Connection.OpenSchema method with the adSchemaDBInfoLiterals constant.
The following sample returns a list of tables in a database.
Public Function GetSchemaTable(ByVal connectionString As String) _ As DataTable Using connection As New OleDbConnection(connectionString) connection.Open() Dim schemaTable As DataTable = _ connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _ New Object() {Nothing, Nothing, Nothing, "TABLE") Return schemaTable End Using End Function
using System; using System.Data; using System.Data.OleDb; class Class1 { static void Main() { string x = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI"; GetSchemaTable(x); Console.ReadLine(); static DataTable GetSchemaTable(string connectionString) { using (OleDbConnection connection = new OleDbConnection(connectionString)) { connection.Open(); DataTable schemaTable = connection.GetOleDbSchemaTable( OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" ); return schemaTable;
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.