代码如下:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.EnginePublic Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer#Region " Web 窗体设计器生成的代码 "    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub#End Region    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        Dim LogonInfo As New TableLogOnInfo()
        Dim oRpt As New ReportDocument()
        oRpt.Load("D:\myweb\creport1\CrystalReport1.rpt")        LogonInfo.ConnectionInfo.ServerName = "bmis-server"
        LogonInfo.ConnectionInfo.DatabaseName = "balance"
        LogonInfo.ConnectionInfo.UserID = "sa"
        LogonInfo.ConnectionInfo.Password = "ddddd"        oRpt.Database.Tables(0).ApplyLogOnInfo(LogonInfo)        '建立.rpt文件与CryStalReportviewer文件之间的连接
        CrystalReportViewer1.ReportSource = oRpt
        CrystalReportViewer1.DataBind()    End SubEnd Class

解决方案 »

  1.   

    重装crystal report 可能是这个问题。
      

  2.   

    还应该帖上出错时的详细信息!--------------------------------
    AspNetPager 免费分页控件4.0版发布,欢迎下载使用:http://www.webdiyer.com
      

  3.   

    example:
    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
    }
      

  4.   

    to xrascal(横刀夺爱):
    我就是根据你的程序改写的VB代码,还是无法执行,报告“未将对象引用设置到对象的实例”错误