C#读取数据库中的表

        private int ExistOrNot(string name)    //判断当前数据表是否存在

        {

            con = new SqlConnection(s);

            DataSet ds = new DataSet();

            string strSQL = "select name from sysobjects where type='" + 'U' + "'";

            sda = new SqlDataAdapter(strSQL, con);

            sda.Fill(ds);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)

            {

                if (ds.Tables[0].Rows[i][0].ToString() == name)

                {

                    return 1;

                }

            }

            return 0;

        }

posted @ 2015-08-27 00:21  best.lei  阅读(1547)  评论(0编辑  收藏  举报