MSSQL

  1. /*列出局域网中所有数据库的电脑名称*/       
  2. private void button1_Click(object sender, EventArgs e)
  3.         {
  4.             SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
  5.             DataTable dt = instance.GetDataSources();
  6.             DisplayData(dt);
  7.         }
  8.         private  void DisplayData(System.Data.DataTable table)
  9.         {
  10.             foreach (System.Data.DataRow row in table.Rows)
  11.             {
  12.                 //RichTextB
  13.                 richTextBox1.Text+=String.Format("服务器名 = {0} /t", row["ServerName"]);
  14.                 richTextBox1.Text+=String.Format("实例名 = {0}/t", row["InstanceName"]);
  15.                 richTextBox1.Text+=String.Format("是否集成验证 = {0}/t", row["IsClustered"]);//即Windows身份验证和SQL Server验证
  16.                 richTextBox1.Text += String.Format("版本 = {0} /t", row["Version"]);//8.*是SQL 2000,9.*是SQL 2005
  17.                 richTextBox1.Text += String.Format("/r/n");
  18.             }
  19.         }
  1. /*选择所有表名*/
  2. SELECT   *   FROM   sysobjects   WHERE   xtype='U'   
  3.     
  4.   U   =   User   table   
  5.     
  6.   /*   
  7.   xtype   char(2)   Object   type.   Can   be   one   of   these   object   types:     
  8.   C   =   CHECK   constraint   
  9.   D   =   Default   or   DEFAULT   constraint   
  10.   F   =   FOREIGN   KEY   constraint   
  11.   L   =   Log   
  12.   FN   =   Scalar   function   
  13.   IF   =   Inlined   table-function   
  14.   P   =   Stored   procedure   
  15.   PK   =   PRIMARY   KEY   constraint   (type   is   K)   
  16.   RF   =   Replication   filter   stored   procedure     
  17.   S   =   System   table   
  18.   TF   =   Table   function   
  19.   TR   =   Trigger   
  20.   U   =   User   table   
  21.   UQ   =   UNIQUE   constraint   (type   is   K)   
  22.   V   =   View   
  23.   X   =   Extended   stored   procedure   
  24.     */




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值