如何遍历sql2000数据库,返回库中每个表的表名?

tanc2001 2005-02-24 10:51:30
如何遍历sql2000数据库,返回库中每个表的表名?
...全文
336 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
mobydick 2005-02-24
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/ShowDetail.aspx?id=BCEAADFB-CFF3-4804-B3B3-6C7D6488982B
这个最快
doubon 2005-02-24
  • 打赏
  • 举报
回复
select name from sysobjects where xtype = 'U' and name <> 'dtproperties'
chinasqf 2005-02-24
  • 打赏
  • 举报
回复
SELECT name FROM sysobjects WHERE (xtype = 'u')
rachy 2005-02-24
  • 打赏
  • 举报
回复
SELECT name FROM sysobjects WHERE (xtype = 'u')

sqlserver本身就是一个系统,记录了所有用户更改的信息
web_gus 2005-02-24
  • 打赏
  • 举报
回复
学习
jialiang 2005-02-24
  • 打赏
  • 举报
回复
SELECT name FROM sysobjects WHERE (xtype = 'u')
whmjw 2005-02-24
  • 打赏
  • 举报
回复
添加Sqldmo的引用,再用下面的函数加到listbox中去
服务器名 数据库名 用户名 密码
private void GetTableList(string strServerName,string strDBName,string strUserName,string strPwd)
{
this.listBox2.Items.Clear();
string strConStr = " data source="+ strServerName +";initial catalog="+strDBName +
";password="+ strPwd+";persist security info=True;user id="+ strUserName;
SqlConnection conn = new SqlConnection(strConStr) ;
ArrayList alTbs = new ArrayList() ;

string strSql="select * from sysobjects where (xtype='u' or xtype='p') and category<>2 order by name";
SqlCommand comm=new SqlCommand(strSql,conn);
SqlDataReader dr=null;

conn.Open();
dr=comm.ExecuteReader();
//frmWizard.alist.Clear();
while(dr.Read())
{
string strName=dr["name"].ToString();
bool blTable=dr["xtype"].ToString().Trim().ToUpper()=="U"?true:false;
if(blTable==true)
{this.listBox2.Items.Add(strName);}
}
}
miaowei127 2005-02-24
  • 打赏
  • 举报
回复
可以从系统数据库MASTER中sysdatabases表中取
DongCd 2005-02-24
  • 打赏
  • 举报
回复
SELECT name FROM sysobjects WHERE (xtype = 'u')

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧