我在下面的代码中遇到2个错误。第一个错误只是赋值,调用,递增,递减可以用作语句。第二个错误是方法setDataSource取0参数没有重载。
ReportDocument rptDoc = new ReportDocument();
DataSet1 ds = new DataSet1();
DataTable dt = new DataTable();
dt.TableName = "Report sample";
dt = getAllOrders();
ds.Tables[0].Merge[dt]; **<---first error**
rptDoc.Load(Server.MapPath("~/CrystalReport.rpt"));
rptDoc.SetDataSource(); **<--second error**
CrystalReportViewer1.ReportSource = rptDoc;
public DataTable getAllOrders(){
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd= new SqlCommand("Select * from userTable",conn);
DataSet ds = null;
SqlDataAdapter dta;
try{
conn.Open();
ds = new DataSet();
dta = new SqlDataAdapter(cmd);
dta.Fill(ds,"userName");
conn.Close();
}catch(Exception ex){
throw new Exception(ex.Message);
}finally{
cmd.Dispose();
if(conn.State!=ConnectionState.Closed)
conn.Close();
}
return ds.Tables[0];
}