分类: 数据库开发技术
2008-05-28 15:36:55
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;{
TableLogOnInfo log = new TableLogOnInfo();
log.ConnectionInfo.ServerName = "wudi";
log.ConnectionInfo.DatabaseName = "YabOA";
log.ConnectionInfo.UserID = "asp.net";
log.ConnectionInfo.Password = "exit";
ReportDocument rd = new ReportDocument();
string RptPath = null;
RptPath =Server.MapPath("CrystalReport2.rpt");
rd.Load(RptPath);
rd.Database.Tables[0].ApplyLogOnInfo(log);this.CrystalReportViewer1.ReportSource = rd;
this .CrystalReportViewer1.DataBind();
}
using CrystalDecisions.Shared;
using System.Configuration;{
string connectString = "server=.;user id=ASP.NET;initial catalog=Yaboa;password=exit";
SqlConnection MyConnection = new SqlConnection(connectString);
MyConnection.Open();
string sqlstring = "select xh,sh,qy from baseinfoVwOfZb";SqlDataAdapter MyCommand = new SqlDataAdapter(sqlstring,MyConnection);
DataSet ds = new DataSet();
MyCommand.Fill(ds,"baseinfoVwOfZb");
YabOA.CrystalReport1 cr1 = new YabOA.CrystalReport1();
cr1.SetDataSource(ds.Tables["baseinfoVwOfzb"]);
this.CustomerOrderCRViewer.ReportSource = cr1;}
在web中和在windowsApplication中水晶报表的使用略有不同。在Web中经常会遇到权限的问题。