應用ADO.net得到系統資料表資訊

來源:互聯網
上載者:User
ado '---------------------------------------------------------- '開發人員:趙玉 '開發時間:2005.1.13 '功能:應用ADO.net得到表 '---------------------------------------------------------- Imports Zy_DataAccess Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Data.OleDb Public Class ClsGetTables '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得到所有表 '---------------------------------------------------------- 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, Nothing, Nothing}) ' "TABLE"}) conn.Close() Return schemaTable End Function '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得系統資料表 '---------------------------------------------------------- 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, Nothing, Nothing, "SYSTEM TABLE"}) conn.Close() Return schemaTable End Function '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得使用者表 '---------------------------------------------------------- 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, Nothing, Nothing, "TABLE"}) conn.Close() Return schemaTable End Function '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得到系統檢視表 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得到使用者視圖 '---------------------------------------------------------- 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, Nothing, Nothing, "VIEW"}) ' "TABLE"}) conn.Close() Return schemaTable End Function '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得到所有過程 '---------------------------------------------------------- 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, Nothing, Nothing}) conn.Close() Return schemaTable End Function '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得到資料類型 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:得到表的列,My_Tablename為空白是所有的 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫名 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫表列的許可權 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫表的索引 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫表的主鍵 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫的預存程序的參數 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫的架構資訊 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫的表的記錄數統計 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫的表的記錄數統計 '---------------------------------------------------------- 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 '---------------------------------------------------------- '開發時間:2004.9.9 '功能:資料庫的中使用者可訪問的表 '---------------------------------------------------------- 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


相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。