Application Ado.net get system table information

Source: Internet
Author: User
ADO '----------------------------------------------------------' Developer: Zhao Yu ' development time: 2005.1.13 ' function: Application ado.net get table '--------- -------------------------------------------------Imports Zy_dataaccess Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Data.OleDb public Class clsgettables '----------------------------------------- -----------------' Development time: 2004.9.9 ' function: Get all tables '----------------------------------------------------------public Function Getalltables (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables, _ New Object () {Nothing, no, Nothing, nothing}) ' "TABLE"} conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Get system table '----------------------------------------------------------Public function getsystemtables (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables, _ New Object () {Nothing, no, nothing, "SYSTEM TABLE"}) Conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Get user table '----------------------------------------------------------public function getusertables (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables, _ New Object () {Nothing, no, nothing, "TABLE"}) Conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Get system View '----------------------------------------------------------Public function getsystemviews (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables, _ New Object () {Nothing, nothing, nothing, ' SYSTEM VIEW '} ' ' TABLE '} conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Get user view '----------------------------------------------------------public function getuserviews (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables, _ New Object () {Nothing, no, nothing, "VIEW"}) ' "TABLE"} conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Get all procedures '----------------------------------------------------------public function getstoredprocedures (ByVal Cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.procedures, New Object () {Nothing, no, Nothing, nothing}) conn. Close () Return schematable end FunctiOn '----------------------------------------------------------' development time: 2004.9.9 ' function: Get data type '------------------------ ----------------------------------public Function getdatatypes (ByVal cnstr as String) as DataTable Dim Conn as New Oledbc Onnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.provider_types, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Gets the table column, My_tablename is empty is all '----------------------------------------------------------public Function Gettablecolumns (ByVal cnstr As String, ByVal My_tablename as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) C Onn. Open () If My_tablename.trim = "" Then my_tablename = Nothing End If Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Columns, New Object () {Nothing, no, My_tablename, nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' Development time: 2004.9.9 ' function: Database name '-------------------------------------------------- --------Public Function getdbname (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.catalogs, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Features: Database table column permissions '----------------------------------------------------------public function getcolumn_privileges (ByVal Cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.column_privileges, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Index of database table '----------------------------------------------------------public function getindexes (ByVal CnStr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (oledbschemaguid.indexes, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Database table's primary key '----------------------------------------------------------public function Getprimary_keys (ByVal cnstr As String) as the DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Primary_Keys, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Parameters of the stored procedure of the database '----------------------------------------------------------public function getprocedure_parameters (ByVal cnstr as String) As DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Procedure_parameters, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Features: Database schema information '----------------------------------------------------------public function getschemata (ByVal cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.schemata, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Function: Database table records statistics '----------------------------------------------------------public function getstatistics (ByVal Cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.statistics, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Features: Records statistics for tables of database '----------------------------------------------------------public function gettable_statistics ( ByVal Cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.table_statistics, New Object () {nothing}) conn. Close () Return schematable end Function '----------------------------------------------------------' development time: 2004.9.9 ' Features: Tables----------------------------------------------------------public Function Gettables_info (ByVal) that are accessible to users in the database Cnstr as String) as DataTable Dim Conn as New OleDbConnection (CNSTR) Conn. Open () Dim schematable as DataTable = conn. GetOleDbSchemaTable (Oledbschemaguid.tables_info, New Object () {nothing}) conn. Close () Return schematable end Function End Class


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.