getschema

Query vs. C# method to retrieve database metadata

天大地大妈咪最大 提交于 2019-12-24 11:27:07
问题 I need to retrieve for each table in the database the following info: All columns names For each column its type Type max length The possible way to do that is to run a query (even can execute it using await, i.e. async): select object_NAME(c.object_id), c.name, t.name, c.max_length from sys.columns c INNER JOIN sys.types t ON t.system_type_id = c.system_type_id On the other hand there is GetSchema method on connection which makes the same: DataTable columns = connection.GetSchema

How to retrieve actual OleDb table schema (excluding additional table columns)

喜夏-厌秋 提交于 2019-12-20 04:50:14
问题 When I run this code it is also retrieving some other fields which are not present in the table. How can I overcome this? Dim conn As New OleDb.OleDbConnection 'Create a connection string for an Access database Dim strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\check\a.mdb" 'Attach the connection string to the connection object conn.ConnectionString = strConnectionString 'Open the connection conn.Open() Dim Restrictions() As String = {Nothing, Nothing, selected,

Getting system tables and views thru SqlConnection

不问归期 提交于 2019-12-11 21:19:15
问题 I am trying to get all tables from a LocalDB database in C# (VS 2012) When using an OleDbConnection I can do string[] restrictions = new string[4]; connection.GetSchema("Tables", restrictions); and it will return all user tables, all system views and all system tables How can I do this with a SqlConnection ? It seems that GetSchema on a SqlConnection only returns user tables and views, but no system tables or views. The 4th restriction parameter only seems to accept VIEW and BASE TABLE.

How to retrieve actual OleDb table schema (excluding additional table columns)

点点圈 提交于 2019-12-02 03:07:44
When I run this code it is also retrieving some other fields which are not present in the table. How can I overcome this? Dim conn As New OleDb.OleDbConnection 'Create a connection string for an Access database Dim strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\check\a.mdb" 'Attach the connection string to the connection object conn.ConnectionString = strConnectionString 'Open the connection conn.Open() Dim Restrictions() As String = {Nothing, Nothing, selected, Nothing} Dim CollectionName As String = "Columns" Dim dt As DataTable = conn.GetSchema(CollectionName,