473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CrystalDecisions.CrystalReports.Engine.LoadSaveRep ortException when OpenSubreport() was called

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/...s/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.InvalidArg umentException'
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.
Nov 16 '05 #1
4 11382
Can you provide some code?

"anannj" <be*****@gmail.com> wrote in message
news:d7**************************@posting.google.c om...
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/...s/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.InvalidArg umentException'
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.

Nov 16 '05 #2
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" <ra**@nowhere.com> wrote in message news:<er**************@tk2msftngp13.phx.gbl>...
Can you provide some code?

"anannj" <be*****@gmail.com> wrote in message
news:d7**************************@posting.google.c om...
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/...s/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.InvalidArg umentException'
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.

Nov 16 '05 #3
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.LastIn dexOf(".") + 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.LastIn dexOf(".") + 1)
End If
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
End If
Next
Next

crystalReportViewer.ReportSource = crReportDocument

End Sub
>>>>>>>>>>>>>>>>>>>>

Cheers, Peter

"anannj" wrote:
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" <ra**@nowhere.com> wrote in message news:<er**************@tk2msftngp13.phx.gbl>...
Can you provide some code?

"anannj" <be*****@gmail.com> wrote in message
news:d7**************************@posting.google.c om...
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/...s/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.InvalidArg umentException'
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.

Nov 16 '05 #4
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" <Pe********@discussions.microsoft.com> wrote in message news:<D3**********************************@microso ft.com>...
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.LastIn dexOf(".") + 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.LastIn dexOf(".") + 1)
End If
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
End If
Next
Next

crystalReportViewer.ReportSource = crReportDocument

End Sub
>>>>>>>>>>>>>>>>>>>>>>


Cheers, Peter

"anannj" wrote:
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" <ra**@nowhere.com> wrote in message news:<er**************@tk2msftngp13.phx.gbl>...
Can you provide some code?

"anannj" <be*****@gmail.com> wrote in message
news:d7**************************@posting.google.c om...
> 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/...s/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.InvalidArg umentException'
> 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.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stijn Lambert | last post by:
Hi all, I am having some problems with Crystal Reports 9 for Visual Studio .NET ... I have a multithreaded application that prints reports in several threads (based upon incoming requests on a...
2
by: Volkan Karaboša | last post by:
I have an aspx that contains a report prepared with crystal report, when I try to run myapp. on another server which has no crystal report tool installed on it. I receive following error code even...
0
by: Susil Patro | last post by:
Hi all, I have installed Visual Studio dot net version 2003, in my machine. I opened a new project for developing an application related to crystal reports. I got the following error, while I...
0
by: Alixx Skevington | last post by:
OK, I am confused here, so I hope that somebody out there can help me out. I am trying to run a report allows me to choose the report and then change the logon info for it. Noiw before you say...
3
by: Lorenc | last post by:
Is anybody experiencing the following error when trying to export a crystal report to a pdf? This error happens randomly. ------------------------------------------------------------------------...
0
by: Ethorsen | last post by:
Hello, is there a way to use a crystal report version 10 with the modules that comes with framework v1.1 When i try to open the crystal, it always tell me: .F(String  ,...
1
by: Learner | last post by:
Hi Friends, I am building the dataset programmatically by calling the stored proc by passing a parameter and i am getting the data into the dataset. As a test when i bind this dataset to a...
0
by: Dipen | last post by:
Hello All, I am using crystal report in my application. Everything is right but i end up with the following error. Failed to open a rowset. Description: An unhandled exception occurred during...
0
by: PrakashN | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.