This error message appears because the Crystal Reports for Visual Studio .NET (CR for VS .NET) engine does not have the granted permissions to the SQL Server database objects. The type of authentication method you use determines the granted permissions.The two authentication methods are:· Anonymous access· Integrated Windows authenticationAnonymous access uses the Internet Guest account by default. This account is local to the web server computer and needs to be granted permissions to the SQL Server database objects. Alternatively, you can specify a different account to be used for Anonymous access.If the Integrated Windows authentication method is used, then the NT user account logged on to the client computer will determine what permissions are granted to the CR for VS .NET engine on the Web server. All NT users that need to refresh reports will require the necessary permissions to the SQL Server database objects.If the Web server and the SQL Server are on separate computers, then there may be issues with authenticating users through IIS. Refer to the Microsoft knowledge base article Q176377 (found at http://support.microsoft.com) for more information.

解决方案 »

  1.   

    总结了一下:
    如果数据库密码为空的话(我的测试是user id=sa;pwd=)可以直接使用下面代码:
    CrystalReportViewer1.ReportSource = Server.MapPath("cr1.rpt");
    CrystalReportViewer1.DataBind();如果数据库密码不为空的话,则应该添加以下代码安全登陆:ReportDocument Report = new ReportDocument();
    Report.Load(Server.MapPath("cr1.rpt"));
    TableLogOnInfo logOnInfo = new TableLogOnInfo();//对报表中的每个表进行循环
    for(int i=0;i==Report.DataBase.Tables.Count-1;i++)
    {
       logOnInfo.ConnectionInfo.UserId = "sa";
       logOnInfo.ConnectionInfo.Password = "yourpwd";
       Report.DataBase.Tables[i].ApplyLogOnInfo(logOnInfo);
    }
    CrystalReportViewer1.ReportSource = Report;
    CrystalReportViewer1.DataBind();
    //当然如果密码为空的话也同样可以使用这种方法的以上代码需要
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;我试着把数据库登陆密码设为空,成功了。但是密码不为空的时候下面的代码应该写在哪里?能提供一下vb.net的代码么?