Apply ado.net to get the table

Source: Internet
Author: User

'----------------------------------------------------------
'Developer:
'Development time: 2004.9.9
'Function: Use ado.net to obtain the 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: obtain 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, nothing}) '"table "})
Conn. Close ()
Return schematable
End Function
'----------------------------------------------------------
'Development time: 2004.9.9
'Function: Obtain the 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, "system table "})
Conn. Close ()
Return schematable
End Function
'----------------------------------------------------------
'Development time: 2004.9.9
'Function: Obtain the 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, "table "})
Conn. Close ()
Return schematable
End Function
'----------------------------------------------------------
'Development time: 2004.9.9
'Function: Get the 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, "System View"}) '"table "})
Conn. Close ()
Return schematable
End Function
'----------------------------------------------------------
'Development time: 2004.9.9
'Function: Get the 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, "View"}) '"table "})
Conn. Close ()
Return schematable
End Function
'----------------------------------------------------------
'Development time: 2004.9.9
'Function: Get all processes
'----------------------------------------------------------
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, nothing })
Conn. Close ()
Return schematable
End Function
'----------------------------------------------------------
'Development time: 2004.9.9
'Function: Get the Data Type
'----------------------------------------------------------
Public Function getdatatypes (byval cnstr as string) as datatable
Dim conn as new oledbconnection (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: Obtain the table columns. If my_tablename is null, all columns are obtained.
'----------------------------------------------------------
Public Function gettablecolumns (byval cnstr as string, byval my_tablename as string) as datatable
Dim conn as new oledbconnection (cnstr)
Conn. open ()
If my_tablename.trim = "" then
My_tablename = nothing
End if
Dim schematable as datatable = conn. getoledbschematable (oledbschemaguid. columns, new object () {nothing, nothing, 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
'Function: Permission for database Columns
'----------------------------------------------------------
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 the 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: Primary Key of the database table
'----------------------------------------------------------
Public Function getprimary_keys (byval cnstr as string) as 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: database stored procedure parameters
'----------------------------------------------------------
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
'Function: database architecture 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 record count 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
'Function: Database Table record count statistics
'----------------------------------------------------------
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
'Function: tables accessible to users in the database
'----------------------------------------------------------
Public Function gettables_info (byval 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.