Skip to Content
0
Former Member
Oct 13, 2006 at 09:39 PM

Attempted to read or write protected memory.

30 Views

Can someone please help me.

I have a number of reports defined in Crystal 10 reading data tables on SQL server over an intranet.

I have created a simple windows application to view these reports using a crystal viewer object in VB.NET.

This works fine on the original target machine but when I came to install it on other machines I found that it would work on some but not others.

The error returned is

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

which changes to

Object reference not set to an instance of an object

The program is creating the exception when setting the reportsource method in the viewer.

The other thing that I have discovered is that if the report is made up of only one table it works on all machines but if there is more than one it returns this error on some.

Does anyone know why it would work on some machines but not others.

I am new to programming and this is driving me mad.

Thanks

Sub SQL_Connection()
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectioninfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table

Dim rpt As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()

Dim crReportDocument As New ReportDocument()


'load report and connect to database applying password to each table

crReportDocument.Load(ReportPath)

With crConnectioninfo
.ServerName = "XXXXXX"
.DatabaseName = "XXXXXXXX"
.UserID = "XXXXXX"
.Password = "XXXXXX"
End With

CrTables = crReportDocument.Database.Tables

'loop through and apply logon info
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectioninfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

'view report
rptViewer.ReportSource = crReportDocument

End Sub