I am developing window form application using VS2008 and try to view report with Crystal ActiveX Report Viewer 11_5(Support Khmer Unicode). when runtime i need to change datasource of report as Build-in Crystal Report Viewer in VS 2008 can but i always got this error sms "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Here is my code:
Dim FRM As New frmOtherReport
Dim app As New CRAXDDRT.Application
Dim rpt As CRAXDDRT.Report
Dim tbl As CRAXDDRT.DatabaseTable
Dim tbls As CRAXDDRT.DatabaseTables
rpt = app.OpenReport(ReportsURL + "rptStudentListAll.rpt")
For Each tbl In rpt.Database.Tables
tbl.ConnectionProperties.DeleteAll()
tbl.ConnectionProperties.Add("Provider", "SQLOLEDB")
tbl.ConnectionProperties.Add("Data Source", My.Settings.Datasource)
tbl.ConnectionProperties.Add("Initial Catalog", My.Settings.Database)
'tbl.ConnectionProperties.Add("Integrated Security", "True") ' cut for sql authentication
tbl.ConnectionProperties.Add("User Id", My.Settings.Username) ' add for sql authentication
tbl.ConnectionProperties.Add("Password", My.Settings.Password) ' add for sql authentication
Next tbl
'This removes the schema from the Database Table's Location property.
tbls = rpt.Database.Tables
For Each tbl In tbls
With tbl
.Location = .Name
End With
Next
'View the report
rpt.Database.Tables(1).SetDataSource(myDataTable) 'error location
FRM.AxCrystalActiveXReportViewer1.ReportSource = rpt
FRM.AxCrystalActiveXReportViewer1.ViewReport()
FRM.Show()
Any advice appreciated.