日期:2011-12-01  浏览次数:20504 次

'---------------------------------------------------------- '开发者:赵玉 '开发时间: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,