111,097
社区成员




private void Form_PushReport_Load(object sender, EventArgs e)
{
SqlConnection conn = DBConnection.MyConnection();
conn.Open();
try
{
string sql = "SELECT * FROM "+table;//table是表的名字的字符串
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "tmpTable");
string reportPath = System.Windows.Forms.Application.StartupPath + @"CrystalReport_Push.rpt";
ReportDocument rd = new ReportDocument();
rd.Load(reportPath);
rd.SetDataSource(ds.Tables[0].DefaultView);
this.crystalReportViewer1.ReportSource = rd;
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());//一直抛出异常,提示报表加载失败
}
finally
{
conn.Close();
}
}
string sql = "SELECT * FROM "+table;//table是表的名字的字符串
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();//DataSet是在vs中添加的数据集
sda.Fill(ds, "tmpTable");
这些代码不能将table中的数据写到ds中吗?
rd.Load(AppDomain.CurrentDomain.BaseDirectory + "/CrystalReport1.rpt");