获取数据库所有表名与字段名

来源:互联网 发布:一元购物哪个软件好 编辑:程序博客网 时间:2024/04/30 00:18

获取数据库所有表名与字段名

http://www.diybl.com/ 2007-9-8  网络 点击: 419  [ 评论 ]
<script language="JavaScript" src="http://cpro.baidu.com/cpro/ui/cp.js" type="text/javascript"></script>
   protected void GetWhdump()    {        string strSql = "select name from sysobjects where type='U' ";;        StringBuilder Filedstring  = new StringBuilder();        string tempstr;        // DataSet dsWhdump = useraction.LocalhostDao.GetDataSet(strSql);        DataSet dsWhdump;        if (!useraction.RemotingDao.Get_DataSet(strSql, -1, out dsWhdump))        {        }        else        {            if (dsWhdump.Tables[0].Rows.Count == 0)            {                return;            }            else            {                foreach(DataRow temproe in dsWhdump.Tables[0].Rows)                {                    tempstr = GetFieldstr(temproe[0].ToString().Trim());                    Filedstring.Append(tempstr);                }                this.txtDescription.Text = Filedstring.ToString();            }                   }                  }    protected string GetFieldstr(string tablename)    {        string strSql = "Select Name from SysColumns Where id=Object_Id('" + tablename + "') ";        string tempstr=null;               DataSet dsWhdump;        if (!useraction.RemotingDao.Get_DataSet(strSql, -1, out dsWhdump))        {        }        else        {            if (dsWhdump.Tables[0].Rows.Count == 0)            {                return null;            }            else            {                tempstr += "case /"" + tablename + "/":/n return new string [] {";                foreach (DataRow temproe in dsWhdump.Tables[0].Rows)                {                    tempstr +="/""+ temproe[0].ToString().Trim()+"/",";                }                tempstr += "};/n";            }        }        return tempstr;    }
原创粉丝点击