日期:2014-05-17  浏览次数:20765 次

vs2010 的reportview 自定义报表
我用vs2010 的reportview 
做报表,
但是好像没有用到reportview 的datasource.
我该怎么改?
我该怎么操作?
请详细一些,谢谢。


 MySqlConnection connection = new MySqlConnection(MyConnectionString);
                MySqlCommand cmd_db = connection.CreateCommand();
                cmd_db.CommandText = "SELECT auto_id,db_domain,db_ip,db_id,db_enable, ";
                cmd_db.CommandText += " FROM_UNIXTIME(db_write_date) as db_write_date1 ";
                cmd_db.CommandText += " FROM ent_db WHERE db_contract_id =1";
                MySqlDataAdapter adap_db = new MySqlDataAdapter(cmd_db);
                DataSet ds_db = new DataSet();
                adap_db.Fill(ds_db);

                try
                {
                    reportViewer1.Visible = true;

                    ReportDataSource rds = new ReportDataSource("DataSet1_Sales_by_Year", ds_db.Tables[0]);

                    reportViewer1.LocalReport.DataSources.Clear();
                    reportViewer1.LocalReport.DataSources.Add(rds);
                    
                    this.textBox1.Text = ds_db.Tables[0].Rows[0]["db_domain"].ToString();
                    this.textBox2.Text = ds_db.Tables[0].Rows[0]["db_ip"].ToString();
                    reportViewer1.LocalReport.Refresh();