2009-10-22 90 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;