当前位置: 代码迷 >> ASP.NET >> datalist控件的数据库有关问题
  详细解决方案

datalist控件的数据库有关问题

热度:1367   发布时间:2013-02-26 00:00:00.0
datalist控件的数据库问题
protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                if   (!IsPostBack)
                {

                        string   MySqlConnection   =   "user   id=sa;password=;Database   =pubs;data   source=127.0.0.1;Connect   Timeout=30 ";
                        SqlConnection   conn   =   new   SqlConnection(MySqlConnection);
                 

                        string   sql   =   "select   *   from   stores ";
                        SqlCommand   comm   =   new   SqlCommand(sql,   conn);
                        conn.Open();

                        SqlDataReader   dr   =   comm.ExecuteReader();
                     
                        DataList1.DataSource   =   dr;
                        DataList1.DataBind();
                        conn.Close();
}
什么错都没有报  运行结果什么都看不见 就是一个空白网页

------解决方案--------------------------------------------------------
换成dataset看看。