GetSchemaTable Method (VistaDBDataReader)
In This Topic
Returns a System.Data.DataTable that describes the column metadata of the System.Data.Common.DbDataReader.Create a DataTable containing DataColumn objects that correspond to the columns returned by your query.
Syntax
'Declaration
Public Overrides NotOverridable Function GetSchemaTable() As System.Data.DataTable
'Usage
Dim instance As VistaDBDataReader
Dim value As System.Data.DataTable
value = instance.GetSchemaTable()
public override System.Data.DataTable GetSchemaTable()
Return Value
A System.Data.DataTable that describes the column metadata.A DataTable that describes the column metadata.
Exceptions
Exception | Description |
System.InvalidOperationException | The System.Data.SqlClient.SqlDataReader is closed. |
Example
using (VistaDBConnection cn = new VistaDBConnection("Data Source=|DataDirectory|Database1.vdb6;"))
{
cn.Open();
using (VistaDBCommand cmd = new VistaDBCommand("Select * from employees", cn ) )
{
using (VistaDBDataReader myReader = cmd.ExecuteReader(CommandBehavior.KeyInfo))
{
//Retrieve column schema into a DataTable.
DataTable schemaTable = myReader.GetSchemaTable();
foreach (DataRow myField in schemaTable.Rows)
{
foreach (DataColumn myProperty in schemaTable.Columns)
{
Console.WriteLine(myProperty.ColumnName + " = " +
myField[myProperty].ToString());
}
Console.WriteLine();
}
}
}
}
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also