日期:2014-05-20  浏览次数:20859 次

关于水晶报表使用的一些问题
如下提供一段示例代码供您参考(用来建立数据库链接,填充DataSet,并绑定到报表文件中):      
    private       void       BindReport()      
    {      
    SqlConnection       myConnection       =       new       SqlConnection();      
    myConnection.ConnectionString       =       "Server=localhost;database=pubs;uid=sa;pwd=sa ";      
       
    SqlCommand       myCommand       =       new       SqlCommand();      
    myCommand.Connection       =       myConnection;      
    //在这里根据您的情况,动态指定设定SQL语句      
    myCommand.CommandText       =       "Select       *       from       Stores ";      
    myCommand.CommandType       =       CommandType.Text;        
    SqlDataAdapter       myDA       =       new       SqlDataAdapter();      
    myDA.SelectCommand       =       myCommand;      
      Dataset1       myDS       =       new       Dataset1();      
    myDA.Fill(myDS,       "Stores ");      
问题行1000:CrystalReport1           oRpt       =       new       CrystalReport1();      
    oRpt.SetDataSource(myDS);      
    CrystalReportViewer1.ReportSource       =       oRpt;      
    }      
问题:在上面问题行中,为什么上面别人给的例子里能定义CrystalReport1           oRpt       =       new       CrystalReport1();
但我也做了一个水晶报表文件report1.rpt,为什么不能用上面的语句啊,一用
就说     Report1   oRpt       =       new       Report1();   找不Report1


------解决方案--------------------
再学习一把:你连接数据库是用的oledb还是ado.net,你自己生成了xsd没有?