Crystal Report

Crystal Report

Object reference not set to an instance of an object.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

CrystalReportSource1.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, “Registration Reports”)

This occurs because the Login credentials provided are not valid.  In particular, you cannot change SERVER or DATABASE with

SetDatabaseLogon(User, Password, Server, Database)

See:   http://msdn.microsoft.com/en-us/library/ms227750(v=vs.80).aspx

Code:

              First:        Dim Server As String = ConfigurationManager.AppSettings(“DBServer”)

              Second:    Dim Database As String = ConfigurationManager.AppSettings(“Database”)

              Third:       Dim User As String = ConfigurationManager.AppSettings(“DBUser”)

              Last:         Dim Password As String = ConfigurationManager.AppSettings(“DBPassword”)

 

                ‘ The following set of code is necessary to dynamically change the SERVER and DATABASE.

                Dim ci As CrystalDecisions.Shared.ConnectionInfo = New ConnectionInfo()

                ci.Type = ConnectionInfoType.CRQE

                ci.ServerName = Server

                ci.DatabaseName = Database

                ci.UserID = User

                ci.Password = Password

                Dim tli As TableLogOnInfo = New TableLogOnInfo()

                tli.ConnectionInfo = ci

                Dim t As CrystalDecisions.CrystalReports.Engine.Table

                For Each t In CrystalReportSource1.ReportDocument.Database.Tables

                    t.ApplyLogOnInfo(tli)

                Next t

                CrystalReportSource1.ReportDocument.SetParameterValue(“@var1”, Request.QueryString(“param1”))

                ‘ The following will fail if the login fails:

                ‘        “Object reference not set to an instance of an object”

                ‘        “Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.”

                CrystalReportSource1.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, “Registration Reports”)

 

For more information how Acumen can help with your software needs, contact us today!

Building additional SQL views in Aptify Association and Membership Management Software can sometimes require you to use SQL temporary tables in your view.

If you then attempt to create a database object from said view:

You will get an Aptify Exception error that will include “Views or functions are not allowed on temporary tables. Table names that begin with ‘#’ denote temporary tables.”

To get around this problem:

Take the T-SQL involving the temp table and port it into a table-based function that is called by the view.

The issue comes from the way Aptify enumerates everything returned by the SELECT statement and cannot handle temp tables in a view. Functions don’t have the same restrictions, though, and can be used to return the needed data.

See our Network Page or Contact Us to find more ways we can help you!