新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#信息架構(gòu)視圖
C#語言還是比較常見的東西,這里我們主要介紹C#信息架構(gòu)視圖,包括介紹獲得當前數(shù)據(jù)庫的所有表等方面。

成都創(chuàng)新互聯(lián)專業(yè)提供成都主機托管四川主機托管成都服務(wù)器托管四川服務(wù)器托管,支持按月付款!我們的承諾:貴族品質(zhì)、平民價格,機房位于中國電信/網(wǎng)通/移動機房,成都IDC機房托管服務(wù)有保障!
C#信息架構(gòu)視圖
C#信息架構(gòu)視圖是sql-92 標準中定義的架構(gòu)視圖,這些視圖獨立于系統(tǒng)表。C#信息架構(gòu)視圖的***優(yōu)點是,即使我們對系統(tǒng)表進行了重要的修改,應(yīng)用程序也可以正常地使用這些視圖進行訪問。下面的示例使用信息架構(gòu)視圖來工作。
- private void GetTables_INFORMATION_SCHEMA()
- {
- //打開連接
- string strConnectionString=System.Configuration.
ConfigurationSettings.AppSettings["ConnectionString"];- sqlcn=new SqlConnection(strConnectionString);
- sqlcn.Open();
- //使用信息架構(gòu)視圖
- SqlCommand sqlcmd=new SqlCommand
("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.
TABLES WHERE TABLE_TYPE = 'BASE TABLE'",sqlcn);- SqlDataReader dr=sqlcmd.ExecuteReader();
- while(dr.Read())
- {
- MessageBox.Show(dr.GetString(0));
- }
- }
使用系統(tǒng)表
如果您的數(shù)據(jù)庫系統(tǒng)是sqlserver,就可以使用如下的方式來獲得當前數(shù)據(jù)庫的所有表:
- private void GetTables_SystemTable()
- {
- //打開連接
- string strConnectionString=System.Configuration.
ConfigurationSettings.AppSettings["ConnectionString"];- sqlcn=new SqlConnection(strConnectionString);
- sqlcn.Open();
- //使用信息架構(gòu)視圖
- SqlCommand sqlcmd=new SqlCommand
("SELECT OBJECT_NAME (id) FROM sysobjects WHERE xtype =
'U' AND OBJECTPROPERTY (id, 'IsMSShipped') = 0",sqlcn);- SqlDataReader dr=sqlcmd.ExecuteReader();
- while(dr.Read())
- {
- MessageBox.Show(dr.GetString(0));
- }
- }
當前標題:C#信息架構(gòu)視圖
路徑分享:http://www.dlmjj.cn/article/dhgopjs.html


咨詢
建站咨詢
