当前位置: 代码迷 >> ASP.NET >> 为什么DataSet 的值是空?该如何处理
  详细解决方案

为什么DataSet 的值是空?该如何处理

热度:4891   发布时间:2013-02-26 00:00:00.0
为什么DataSet 的值是空??
public   partial   class   Report1   :   System.Web.UI.Page
{
        DataSet   ds   =   new   DataSet();

  protected   void   btn_find_Click(object   sender,   EventArgs   e)
        {
                string   strconn   =   ConfigurationManager.AppSettings[ "dsn "];
                //连接本地计算机的WMS数据库
                SqlConnection   cn   =   new   SqlConnection(strconn);
                string   mysql   =   "SELECT   a.vin,   d.name   AS   operate,   a.operate_time,   a.warehouse,   b.name   AS   driver,   c.name   AS   operator   FROM   Transations   a   INNER   JOIN     Drivers   b   ON   a.driver   =   b.code   INNER   JOIN   Users   c   ON   a.operator   =   c.Uname   INNER   JOIN   TransationCode   d   ON   a.operate   =   d.code   where   (operate= 'movein ')   ";
                //如果仓库有输入
                if   (ddl_warehouse.SelectedIndex   !=   0)
                {
                        mysql   =   mysql   +   "and   a.warehouse= ' "   +   ddl_warehouse.SelectedItem.Text.ToString()   +   " ' ";
                }
                if   (tbx_time1.Text.ToString()   !=   " ")
                {
                        mysql   =   mysql   +   "and   a.operate_time> = ' "   +   tbx_time1.Text.ToString()   +   " ' ";
                }
                if   (tbx_time2.Text.ToString()   !=   " ")
                {
                        mysql   =   mysql   +   "and   a.operate_time <= ' "   +   tbx_time2.Text.ToString()   +   " ' ";
                }
                mysql   =   mysql   +   "   ORDER   BY   a.operate_time ";

                SqlDataAdapter   da   =   new   SqlDataAdapter(mysql,   cn);

                da.Fill(ds);

                GridView1.DataSource   =   ds;

                GridView1.DataBind();

                cn.Close();
              //查询得到一个ds
        }
  相关解决方案