水晶报表无效的类别字符串问题
对于水晶报表,小第刚刚接触,很多地方不是很懂,最近做了关于在C#中用的水晶报表,但是出现问题,在网上找了也没有发现解决的办法,希望能在这里遇到高手帮小第解决这个问题:
问题:在C#中做水晶报表生成总是出现System.Runtime.InteropServices.COMException: 无效的类别字符串
oRpt.Load(strFile); //报错就在这里,说无效的类别字符串
我的代码是:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)// 在此处放置用户代码以初始化页面
{
TableLogOnInfo logOnInfo = new TableLogOnInfo ();
ReportDocument oRpt = new ReportDocument();
string strFile=System.Web.HttpContext.Current.Server.MapPath("CrystalReport1.rpt");
oRpt.Load(strFile);
logOnInfo.ConnectionInfo.ServerName = "LENOVO";
logOnInfo.ConnectionInfo.DatabaseName = "MJDataBase";
logOnInfo.ConnectionInfo.UserID = "sa";
logOnInfo.ConnectionInfo.Password = "";
oRpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
CrystalReportViewer1.ReportSource=oRpt;
}
}