.NETGURU
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException when OpenSubreport() was called
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

anannj
Hi everyone,

I have a Crystal Report with a subreport in a windows application,
which is to be exported to the pdf file. I followed the instructions
on http://support.crystaldecisions.com/library/kbase/articles/c2010275.asp
to set up the log on information. But I always got the exception at
the statement:
tbl.Location = ...;

The error message is listed below:

An unhandled exception of type
'CrystalDecisions.CrystalReports.Engine.InvalidArgumentException'
occurred in crystaldecisions.crystalreports.engine.dll

Additional information: Error in File C:\tmp2\rptMain.rpt:
Invalid table number.

Can anyone help me on this problem? Thank you so much in advance.

-- anannj

p.s. the datasets in the reports were created against views. But I
don't think this could cause any problem.
Reply to this message...
 
    
Frank
Can you provide some code?

"anannj" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
anannj
Here is my code:
/**************************************************************/

Table    crTable;
TableLogOnInfo    crLogOnInfo = new TableLogOnInfo();
ConnectionInfo    crConnInfo = new ConnectionInfo();
foreach(Table tbl in ReportDoc.Database.Tables)
{
    crConnInfo.ServerName = "cia_sql2000";
    crConnInfo.DatabaseName = "cia";
    crConnInfo.UserID = "sa";
    crConnInfo.Password = "#ciasql";
    crLogOnInfo = tbl.LogOnInfo;
    crLogOnInfo.ConnectionInfo = crConnInfo;
    tbl.ApplyLogOnInfo(crLogOnInfo);
    tbl.Location = tbl.Location.Substring(tbl.Location.LastIndexOf(".")+1);
}
/***********************************************************************/

It always failed at the last statement no matter whether I explicitly
provided the location.

"Frank" <Click here to reveal e-mail address> wrote in message news:<Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
    
Peter Jones (VIP)
Hi Anannj,

I think the last two lines in your code should be reversed. Following is the
Vb.Net code I use for CR report init in my apps.

>>>>>>>>>>>>>>>>>>>>>>>>>>>
Private Sub ReportInit(ByVal blRefreshLocation As Boolean)

Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject

Dim crReportDocument As ReportDocument
Dim crSubreportDocument As ReportDocument

Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectioninfo As ConnectionInfo

Dim myArrayList As ArrayList = New ArrayList

'declare an instance of the report and the connectionInfo object

crReportDocument = New ReportDocument
crConnectioninfo = New ConnectionInfo

crReportDocument.Load(mstrReportName)

'pass the necessary parameters to the connectionInfo object
With crConnectioninfo
.ServerName = mstrDBServerName
.DatabaseName = mstrDataBaseName
End With

'set up the database and tables objects to refer to the current report
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables

'loop through all the tables and pass in the connection info
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectioninfo
If blRefreshLocation Then
crTable.Location = mstrDataBaseName & ".dbo." &
crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
End If
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

'set the crSections object to the current report's sections
crSections = crReportDocument.ReportDefinition.Sections

'loop through all the sections to find all the report objects
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
'you will need to typecast the reportobject to a
subreport
'object once you find it
crSubreportObject = CType(crReportObject, SubreportObject)

'open the subreport object
crSubreportDocument =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

'set the database and tables objects to work with the
subreport
crDatabase = crSubreportDocument.Database
crTables = crDatabase.Tables

'loop through all the tables in the subreport and
'set up the connection info and apply it to the tables
For Each crTable In crTables
With crConnectioninfo
.ServerName = mstrDBServerName
End With
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectioninfo
If blRefreshLocation Then
crTable.Location = mstrDataBaseName & ".dbo." &
crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
End If
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
End If
Next
Next

crystalReportViewer.ReportSource = crReportDocument

End Sub

>>>>>>>>>>>>>>>>>>>>>>>>>>>

Cheers, Peter

"anannj" wrote:

[Original message clipped]

Reply to this message...
 
    
anannj
Thanks, Peter.

I swaped the last two statements but the error is still there. It
worked fine if there was no subreport...

Regards,

Anannj

"Peter Jones" <Click here to reveal e-mail address> wrote in message news:<Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
 
System.Collections.ArrayList




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification