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;

        }

原文地址:https://www.cnblogs.com/zhanglei93/p/4762096.html