protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
// 声明所需变量。
TableLogOnInfo logOnInfo = new TableLogOnInfo(); // 这里必须事先申明一个ReportDocument对象 Report,同时加载数据报表
ReportDocument oRpt = new ReportDocument();

string path = Server.MapPath("Report_rpt\\CrystalReport1.rpt"); //oRpt.Load(path); oRpt.Load("D:\\WebApp\\myCrystalReport\\Report_rpt\\CrystalReport1.rpt");
int i = 0; // 对报表中的每个表依次循环。
//for (i=0;i == oRpt.Database.Tables.Count - 1;i++)
//{
// 设置当前表的连接信息。
logOnInfo.ConnectionInfo.ServerName = ConfigurationSettings .AppSettings ["servername"];
logOnInfo.ConnectionInfo.DatabaseName = ConfigurationSettings .AppSettings ["database"];
logOnInfo.ConnectionInfo.UserID = ConfigurationSettings .AppSettings ["userid"];
logOnInfo.ConnectionInfo.Password = ConfigurationSettings .AppSettings ["pass"];
oRpt.Database.Tables [0].ApplyLogOnInfo(logOnInfo);
//}
CrystalReportViewer1.ReportSource = oRpt;
    CrystalReportViewer1.DataBind();
// /crystalreportwebformviewer/images/toolbar/upd.gif
}