Questions tagged [getschematable]

The SqlDataReader.GetSchemaTable method returns a DataTable that describes the column metadata of the SqlDataReader.

The SqlDataReader.GetSchemaTable method returns a DataTable that describes the column metadata of the SqlDataReader.

Column schema information includes the following information about the column:

  • Name;
  • Data type;
  • Size;
  • Whether the column is a primary key field;
  • Whether the column is an autonumber (AutoIncrement) field.

Namespace: System.Data.SqlClient

Assembly: System.Data (in System.Data.dll)

Source:http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getschematable.aspx

18 questions
8
votes
3 answers

How Does GetSchemaTable() Work?

OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader(CommandBehavior.KeyInfo); DataTable dataTable = oleDbDataReader.GetSchemaTable(); How does GetSchemaTable() work? Where does it get its information in RDBMS?
user366312
  • 16,949
  • 65
  • 235
  • 452
6
votes
4 answers

How to get the DataType and Size of a column using the SqlDataReader?

i am trying to get the data type of each column given to do some verification i already tried the getSchemaTable but it only gives me the schema of a table without values. For example , i have a table in my database and a columnname : id_declarant.…
marcAntoine
  • 668
  • 5
  • 19
  • 35
3
votes
2 answers

how do we get the Column Size and dataType from getschemaTable?

I am a newbie and I am trying to retrieve the Column NAme , Size ( max legth ) and DataType from some table in my database , the following code when i execute it expecting it to display all the column types and names ( i didn't find how to refer to…
marcAntoine
  • 668
  • 5
  • 19
  • 35
2
votes
2 answers

ADO.NET GetOleDbSchemaTable

I'm trying to fill DataRelation collection by information, read from database. DataTable schemaTable = oleconnection.GetOleDbSchemaTable( OleDbSchemaGuid.Foreign_Keys, new object[] { null, null, tablename }); But this info…
Ruben
  • 2,488
  • 1
  • 18
  • 22
2
votes
2 answers

Getting all Table name in a database with c#

I am using VS2010 , .Net 4.0, MS SQL SERVER 2008. I thought I know how to get all table names from a Database. But I was wrong. With table names, I get View names as well as. But when i do it for Views, I just only get Views. I have no idea why this…
Abdur Rahim
  • 3,975
  • 14
  • 44
  • 83
1
vote
2 answers

Check if Datatype from schematable and user data match

I'm having a little problem with checking user inputs. I want to check if an input is of a "given" datatype. The problem is in the "given" as you might have guessed :-) I get an SQLschematable via a Datareader. The database can be exchanged, for the…
user964843
1
vote
0 answers

How to get view name from SqlDataReader?

From sql I need to get columns, tables and views names. With this solution I am able to get only base table names and columns but not the view names. SqlDataReader reader = command.ExecuteReader(CommandBehavior.KeyInfo); DataTable schemaTable =…
Nati
  • 11
  • 1
1
vote
1 answer

C# Get base table name along with alias or correlation name from a query

I am trying to parse a SQL query using: SqlDataReader reader = command.ExecuteReader(CommandBehavior.KeyInfo); DataTable schemaTable = reader.GetSchemaTable(); I get base table names, but I also need to find the table alias names. Example…
1
vote
3 answers

What SQL DataTypes to look for?

I wrote a code using c#- Visual 2008- that takes: 1- an excel sheet. 2- Opens a connection to Excel 3- Reads the Column names using the OleDbDataReader object and GetTableSchema method 4- Added the Columns names in an array 5- Created a Table…
1
vote
1 answer

Determining Oracle Column gets filled by sequence and trigger (Identity Column like SQLServer)

I have to determine, if a column gets filled up automatically. Mostly this is done at PrimaryKey Columns. This has to be done with Oracle database as well as with SQLServer. The background of my question is (only for your better understanding), i'm…
Dom84
  • 852
  • 7
  • 20
1
vote
1 answer

Access "IIf" condition messes up schema of table

I have a ms-access file which has some tables that are generated by using joins on other tables in the db file. One of the tables (called "Pin_Codes") has got an access "IIf" condition in the script to populate the column. The SQL script for the…
0
votes
1 answer

Get only table columns with DbConnection.GetSchema method

With C# and SQL Server 2005 and by using DbConnection.GetSchema() method, I want to get all a table's columns (not of views) only. I have found two collection names related to this Columns that returns table and views' columns ViewColumns returns…
user369182
  • 1,995
  • 4
  • 16
  • 17
0
votes
0 answers

GetSchemaTable Columns Missing?

I am using this code to get data from a dataReader into a DataTable which can then be serialised. However, it looks like any column with a null value isnt being written to the xml. I cant see the issue. This is my entire class, and im calling this…
S Rosam
  • 375
  • 1
  • 3
  • 16
0
votes
1 answer

IsAliased always null in GetSchemaTable

GetSchemaTable() always returns IsAliased as null, and BaseColumnName is always the same as ColumnName, even though I have used an alias name to fetch column data from Stored Procedure. SP: SELECT u.Name AS [Display Name] ,code AS [Display…
user5663970
  • 119
  • 2
  • 13
0
votes
2 answers

reader.GetSchemaTable on Oracle database does not return a DataTypeName column

Doing a table = reader.GetSchemaTable(); on sql server 2005 returns me a column DataTypeName to find out the datatype of my select statement. Doing the same code on a oracle server returns me NO DataTypeName column. How do you then get the datatype…
msfanboy
  • 5,273
  • 13
  • 69
  • 120
1
2