2009-10-22 53 views
-2
/* protected void Page_Load(object sender, EventArgs e) 
{ 
     //--Sql string 
    string strId1; 
    strId1=Request["empid"].ToString(); 

    string strId2; 
    strId2 = Request["empid1"].ToString(); 

    String strCmd = ""; 
    strCmd += "Select YKCODE,NAME,RNAME,TICODE,MADKBN,MKCODE,TANKBN,YOUKBN,KOUCODE "; 
    strCmd += "From GMYAKU "; 
    if(strId1!="" && strId2!="") 
    { 
    strCmd += "where YKCODE BETWEEN " + strId1 + " AND " + strId2; 
    } 

    //--Opening Sql Connection 
    string strConn = ConfigurationManager.AppSettings["ConnectionString"]; 
    SqlConnection sqlConn = new SqlConnection(strConn); 
    DataSet ds = new DataSet(); 
    SqlDataAdapter da = new SqlDataAdapter(strCmd, sqlConn); 

    //--this statement is very important, here the table name should 
    //--match with the XML Schema table name 
    da.Fill(ds, "GMYAKU"); 

    //--Closing Sql Connection 
    sqlConn.Close(); 

    //--(Optional) I have used it to disable the properties 
    //CrystalReportViewer1.DisplayGroupTree = false; 
    //CrystalReportViewer1.HasCrystalLogo = false; 

    //--Initializing CrystalReport 

    // ReportDocument myReportDocument; 
    //myReportDocument = new ReportDocument(); 
    ReportViewer1.LocalReport("Report1.rdlc"); 


    //--Binding report with CrystalReportViewer 
    ReportViewer1.ReportSource = ReportViewer1; 
    ReportViewer1.DataBind(); 

}*/ 
+0

什么你问这里? – nitzmahone 2009-10-22 06:19:09

+0

代码可能不起作用,因为它的注释掉了? – 2009-10-22 06:28:08

+0

您是使用Crystal Report还是MS Reporting Service?评论说水晶,但代码说MS。 – dotjoe 2009-10-22 14:51:08

回答

1

我不熟悉使用Crystal Reports的这种方式,但我可以看到有一些奇怪的发生的事情与你的ReportSource - 你有指向的ReportViewer本身:

ReportViewer1.ReportSource = ReportViewer1; 

不应该这个是这样的:

ReportViewer1.ReportSource = ds;