Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having a problem while viewing rpt.

It gives invalid report source error while displaying the rpt


Following is the code

I have added Crystal report 8.5 designer runtime library as a ref
VB
Dim CrxApp As CRAXDDRT.Application
Dim CrxRep As CRAXDDRT.Report
Dim crxDatabase As CRAXDDRT.Database
Dim crxDatabaseTables As CRAXDDRT.DatabaseTables
Dim crxDatabaseTable As CRAXDDRT.DatabaseTable

CrxApp = New CRAXDDRT.Application
CrxRep = CrxApp.OpenReport("F:\FabInfo_Repo\Crystal\Report2.rpt")
 
'Set your Database object to the Report object's Database object
crxDatabase = CrxRep.Database

'Set your DatabaseTables object to the Database object's Tables object
crxDatabaseTables = crxDatabase.Tables

'Loop through each DatabaseTable object in the DatabaseTables collection and then set the location of the database file for each table

For Each crxDatabaseTable In crxDatabaseTables
     'Use next line, if you are using Native connection to SQL database
     crxDatabaseTable.SetLogOnInfo("Abcd\SQLExpress", "GSP1011")
Next crxDatabaseTable

        crViewer91.ReportSource = CrxRep
        crxDatabase = Nothing
        crxDatabaseTable = Nothing
        crxDatabaseTables = Nothing
Posted
Updated 6-Feb-11 3:42am
v4
Comments
DaveAuld 5-Feb-11 13:40pm    
Thats unfortunate, but you haven't given enough information to determine what the problems may be.
Sandeep Mewara 6-Feb-11 0:45am    
Share the code part.

1 solution

Try:
crViewer91.ReportSource = @"F:\FabInfo_Repo\Crystal\Report2.rpt";


To look at how you can launch crystal reports, have a look at this article: Creating Crystal Reports using C# with Datasets[^]


BTW, I doubt you can use report from a path and also use data from DB. So, instead of using:
CrxRep = CrxApp.OpenReport("F:\FabInfo_Repo\Crystal\Report2.rpt")

Use,
CrystalReport1 objRpt = new CrystalReport1(); 

and keep rest of the code same. Try out.
 
Share this answer
 
Comments
Espen Harlinn 6-Feb-11 12:10pm    
Good answer, nice link :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900