|
-
Mar 30th, 2007, 04:25 PM
#1
Thread Starter
Junior Member
changing Datasource at runtime CRXI
Hi All and thanks for the help in advance. I have been reading thread after thread trying to figure out how to change the database of a Crystal Reports XI at runtime using VS 2002.
This is what I have so far, it seems like a simple thing to do but I keep getting an error on “crxDatabaseTables = crxReport.Database.Tables”
The error reads,
An unhandled exception of type 'System.InvalidCastException' occurred in PTS.exe
Additional information: Specified cast is not valid.
Any help would be appreciated
Thanks Chuck from Las Vegas
Code:
Dim crxApp As New CRAXDDRT.Application()
Dim crxReport As CRAXDDRT.Report
Dim ReportName As String
Dim crxDatabaseTable As CRAXDDRT.DatabaseTable
Dim crxDatabaseTables As Tables
crxApp = CreateObject("crystalruntime.application.11")
ReportName = System.Windows.Forms.Application.StartupPath & "\" & Frm1.CBReports.SelectedValue
crxReport = crxApp.OpenReport(ReportName)
crxDatabaseTables = crxReport.Database.Tables
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.Location = System.Windows.Forms.Application.StartupPath & "\" & Frm1.FileText
Next crxDatabaseTable
CrystalReportViewer.ReportSource = crxReport
-
Apr 4th, 2007, 04:00 AM
#2
Thread Starter
Junior Member
Re: changing Datasource at runtime CRXI
Can someone please help me with this it is making me crazy..
Thanks Chuck
-
Apr 4th, 2007, 09:45 AM
#3
Re: changing Datasource at runtime CRXI
The Crystal RDC Library does not contain a Tables class, use
Dim crxDatabaseTables As CRAXDDRT.DatabaseTables
-
Apr 5th, 2007, 01:01 AM
#4
Thread Starter
Junior Member
Re: changing Datasource at runtime CRXI
Hi Brucevde,
Thanks for the reply. I will give that a try later, when I get to my other machine.
Chuck
-
Apr 5th, 2007, 07:25 AM
#5
Thread Starter
Junior Member
Re: changing Datasource at runtime CRXI
Thanks that solved the Tables issue. However when previewing the report using
Code:
CrystalReportViewer.ReportSource = crxReport
I get the error “Invalid Report Source”. I changed the report source to
Code:
CrystalReportViewer.ReportSource = ReportName
and I get the report but the database will not change. I can change the report source by supplying the entire path and “reportname.rpt”. But will not change the database.
Any suggestions
Thanks Chuck
Code:
Dim crxApp As New CRAXDDRT.Application()
Dim crxReport As CRAXDDRT.Report
Dim ReportName As String
Dim crxDatabaseTable As CRAXDDRT.DatabaseTable
Dim crxDatabaseTables As CRAXDDRT.DatabaseTables
crxApp = CreateObject("crystalruntime.application.11")
ReportName = System.Windows.Forms.Application.StartupPath & "\" & Frm1.CBReports.SelectedValue
crxReport = crxApp.OpenReport(ReportName)
crxDatabaseTables = crxReport.Database.Tables
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.Location = System.Windows.Forms.Application.StartupPath & "\" & Frm1.FileText
Next crxDatabaseTable
CrystalReportViewer.ReportSource = crxReport
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|