how to get names and count of tables
-
how to get names and count of tables in a database from sqlserver and MSAccess? could u tell me pls?
While some database systems provide that functionality in various ways, with any database system that provides an ADO.net provider, the Connection derives (or should derive*) from
System.Data.Common.DbConnection
, which has aGetSchema
method which returns a DataTable with that information. So I have been using the following:System.Data.Common.DbConnection con =
this.command.Connection as System.Data.Common.DbConnection ;if ( con != null )
{
System.Data.DataTable temp = con.GetSchema
(
"TABLES"
) ;temp.DefaultView.RowFilter = "TABLE_TYPE='TABLE' OR TABLE_TYPE='BASE TABLE'" ;
temp.DefaultView.Sort = "TABLE_NAME" ;This is good enough for SQL Server, Access, and Excel. But this is old code; a week or so ago I started using Oracle and MySql (and FireBird, just because) again and found that the tables provided by them are more different than I expected so I had to adapt. * I'm looking at you Cache. :mad:
-
how to get names and count of tables in a database from sqlserver and MSAccess? could u tell me pls?
-
While some database systems provide that functionality in various ways, with any database system that provides an ADO.net provider, the Connection derives (or should derive*) from
System.Data.Common.DbConnection
, which has aGetSchema
method which returns a DataTable with that information. So I have been using the following:System.Data.Common.DbConnection con =
this.command.Connection as System.Data.Common.DbConnection ;if ( con != null )
{
System.Data.DataTable temp = con.GetSchema
(
"TABLES"
) ;temp.DefaultView.RowFilter = "TABLE_TYPE='TABLE' OR TABLE_TYPE='BASE TABLE'" ;
temp.DefaultView.Sort = "TABLE_NAME" ;This is good enough for SQL Server, Access, and Excel. But this is old code; a week or so ago I started using Oracle and MySql (and FireBird, just because) again and found that the tables provided by them are more different than I expected so I had to adapt. * I'm looking at you Cache. :mad:
PIEBALDconsult wrote:
a week or so ago I started using Oracle and MySql
Poor bastard, you have my sincere sympathies.
Never underestimate the power of human stupidity RAH
-
PIEBALDconsult wrote:
a week or so ago I started using Oracle and MySql
Poor bastard, you have my sincere sympathies.
Never underestimate the power of human stupidity RAH
Yes, thank you. Fortunately all I need to do is pull some data from them and make copies in SQL Server, but I still need to be sure that my data access library works with them.