MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("192.168.0.56", "antshop", "root", "qwe123").AsString);
            conn.Open();
string sql = "SELECT a.salesman,SUM(b.qty/b.qtyOfPackage),b.expiryDate FROM saleorderbill a,saleorderbilldetail b,brand c,goods d WHERE a.billCode=b.billCode AND b.goods_id=d.id AND d.brand_id=c.id AND b.money<>0 AND a.salesman='刘俊斌' GROUP BY a.salesman,c.`name`,b.expiryDate";
            MySQLCommand comm = new MySQLCommand(sql, conn);
            comm.ExecuteNonQuery();
            MySQLDataAdapter da = new MySQLDataAdapter();
            da.SelectCommand = comm;
            DataSet ds = new DataSet();
            da.Fill(ds);
为什么运行的时候ds中没有想要的数据,哪里出了问题?数据库asp.net

解决方案 »

  1.   

    ds.Fill(da);把执行的数据放到ds中
      

  2.   

    楼上的不行的话,你就在数据库中运行看你的SQL语句看看是否能查出数据来。
      

  3.   

     comm.ExecuteNonQuery();//这句去掉
      

  4.   


    MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("192.168.0.56", "antshop", "root", "qwe123").AsString);
                conn.Open();
    string sql = "SELECT a.salesman,SUM(b.qty/b.qtyOfPackage),b.expiryDate FROM saleorderbill a,saleorderbilldetail b,brand c,goods d WHERE a.billCode=b.billCode AND b.goods_id=d.id AND d.brand_id=c.id AND b.money<>0 AND a.salesman='刘俊斌' GROUP BY a.salesman,c.`name`,b.expiryDate";
                MySQLDataAdapter da = new MySQLDataAdapter(sql, conn);
                DataSet ds = new DataSet();
                da.Fill(ds);
      

  5.   

    楼主的C#代码虽然写的不咋地,但好像可以实现功能,下面是我用SqlServer仿照楼主写的一段数据库代码,在SqlDataAdapter的Fill()方法之前同样也执行了一次ExecuteNonQuery(),数据是可以查询到的。
    所以我觉得楼主的问题可能出在sql语句上,另外如果断点设在了Fill()方法处,程序是在Fill()方法执行之前停下来的,此时DataSet对象中还没有被填充数据呢SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["NorthWind"].ToString());
    conn.Open();
    string sql = "select * from Employees";
    SqlCommand comm = new SqlCommand(sql, conn);
    comm.ExecuteNonQuery();
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = comm;
    DataSet ds = new DataSet();
    da.Fill(ds, "emp");grid1.DataSource = ds.Tables["emp"];
    grid1.DataBind();