• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

CR XI: Invalid Index if report is designed using more than 1 dataset datatable

Hi experts, I need some helps here, thanks in advanced~

Development Environment : VS.NET 2003
CR Version: CR XI R2 Developer

Recently I am upgrading all my reports from CR9 to CRXI. I hits many problems in the middle but managed to solve them all except the problem mentioned at the title. Every report are working perfectly, but for all the reports that designed using more than 1 datatable (I used OLE DB->Add command to insert more than 1 tables) keep on prompting me "Invalid Index" error while doing data binding at runtime.

I used to use the similiar code below to do data binding:

---------------------------
DataTable dtTable1;
DataTable dtTable2;

/* some code to get data from database............*/

dtTable1.TableName := "Table1"; //Table1, Table2 is the matched table name in CRXI
dtTable2.TableName := "Table2";

rptDoc.Database.Tables[dtTable.TableName].SetDataSource(dtTable);
rptDoc.Database.Tables[dtTable2.TableName].SetDataSource(dtTable2);
---------------------------

This works in CR9 but not in CRXI. It seems that CRXI only allow SetDataSource to be execute only 1 time no matter how.
I tried took off any one of the table from the report and runtime code and the report works perfectly. I tried using DataSet instead of DataTable, I tried putting all DataTables into one DataSet... but none of them working.

I am stucked now, spent one whole day searching from articles from internet or bugs report from Crystal Decisions but have no luck. Is this the draw back of CRXI that It only support 1 Table if we are using Add Command to design the report? Any of you have experience on this? Pls comment, thanks.

dylan
0
dylanyee
Asked:
dylanyee
  • 6
  • 3
  • 3
  • +2
4 Solutions
 
wykabryanCommented:
No actually the opposite.  CRXI allows you to have many commands, also referred to as virtual tables.  The commands are very similar to a database view.  I do not think you are recieving this error because of the report.  I would believe the problem resides in the database or in the front end.
0
 
dylanyeeAuthor Commented:
thanks wykabryan. In CRXI designer, we could add many commands and runs ok in preview, but in ASP.NET's runtime, it just doesn't allow me to bind more than one DataTable.

I also think that it could be other things causing the problems, but it seems not, because every report works just fine except those have multiple tables. I tried to do a simple testing, create a simple report with 2 tables then create a project just to display this report. The result is pretty disappointed, it still return me "Invalid Indexes"...

If you have time, could you do me a favour to do the same simple testing for me at your site? thanks in advanced.

dylan
0
 
wykabryanCommented:
Yes, we have a couple of report based around 3 command objects linked into a table.  They all run without issues.  Unfortunately, I am not wise in the ways for ASP.NET, but there are many experts (that appear to be off right now) that have knowledge about the front end stuff.
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
wykabryanCommented:
The key here is if you ran it in designer and there was no error, you can rule out the report and database.  Because if there was an indexing error on the database, CR would have screamed about it.  I think the issue resides in the ASP somewhere.
0
 
RickJCommented:
Hello dylanyee,
I have one thought,
I do not know XI or  VS.NET 2003 much but...

I would guess that "Invalid Index" refers to the Tables array index not a DB index. (You probably already know this maybe)
Again I do not know the following calls at all but I would have thought that the following,

rptDoc.Database.Tables[dtTable.TableName].SetDataSource(dtTable);
rptDoc.Database.Tables[dtTable2.TableName].SetDataSource(dtTable2);


could be called like this

rptDoc.Database.Tables[0].SetDataSource(dtTable);
rptDoc.Database.Tables[1].SetDataSource(dtTable2);

Maybe this is worth a try to test.
If this is not even close then please ignore my comment.


0
 
dylanyeeAuthor Commented:
RickJ, I did try the Tables[0]... before, and it still give me the same error. Thanks anyway for your comment.

dylan
0
 
janmariniCommented:
I did notice one thing in your example, you're declaring dtTable1 - but using SetDataSource(dtTable), not SetDataSource(dtTable1)

Have you been able to verify that the code to get data is actually populating *both* tables?

Could there be some kind of problem with linking the tables in the report?

What line does the error occur?

I haven't had to do this (yet) - but will be migrating from VS 2002/CR 9.0 to VS 2003/2005 and CR XI very soon, so I'd be interested in the outcome.  Also, I use ReportDocument and haven't used tables with CR like you are... Wish I could be more help.

0
 
mlmccCommented:
Have you tried it as

rptDoc.Database.Tables[1].SetDataSource(dtTable);
rptDoc.Database.Tables[2].SetDataSource(dtTable2);

Most Crystal arrays are 1 based

mlmcc
0
 
dylanyeeAuthor Commented:
mlmcc, the array in crystal report designer is start from 1, but in .net, the array is still start from 0, I tried your suggestion anyway, but no luck :(

janmarini, sorry that was my typo, i set the correct table to datasource. And i don't think there has any problem with data linking, because the report run perfectly in designer's preview. I tried to create 2 testing projects, one is with CR9 assembly and another with CRXI assembly, pointing to the same report, the CR9 App. give me the result but CRXI's App. gave me the error...

CR XI wasn't that steady and user friendly as I felt, you have to follow certain rules when developing CR XI App. Such as
- You have to bind the data to report and all its subreport first before you set the parameters or else it will give you error.
- You can't pass empty string to parameter.
- In Report designer you won't be able to copy parameters to other reports.
- You can't use Alt+Up / Alt+Down key to arrange parameters sequence anymore.

Anyway... I suggest if CR9/10 already give you what you want, don't upgrade to XI. I upgrade mainly because of the dynamic image and it support more color options in chart.

Dylan
0
 
dylanyeeAuthor Commented:
Just to update some status.
I downgraded my Crystal Report XI Release 2 to Crystal Report XI, and now everthing works like a dream. I have to conclude that there are some bugs in CRXI R2. Below is the environment that I tested, for using "Add Command" to design multiple table report and use databind at runtime:

Environment                          Works?
===============          =====
VS.NET 2003 + CRXIR2           no
VS.NET 2005 + CRXIR2           no
VS.NET 2003 + CRXI               yes

I reported the issue to crystal report, but they denied the bug and claim that CRXIR2 has no such problem, they sent me an sample application but still it didn't work for me. They advised me not to install VS.NET 2003 and VS.NET 2005 in the same machine, that is probably where the error cames from. Anyway, i didn't have time to do testing for them. For those who want to do upgrade from VS.NET 2003 to VS.NET 2005, just take this as a note.

Dylan
0
 
mlmccCommented:
With VS 2005, you need CR XI R2.  All other versions of CR should run on any version of VS.  CR XI should work with VS 2003 and before.

I suspect VS has some common dlls and CR has a problem with them

mlmcc
0
 
janmariniCommented:
That's interesting to know... I have VS 2003 and 2005 installed on the same machine, and plan on installing CR XI sometime this week.  I'll let you know if I run into similar problems...
0
 
dylanyeeAuthor Commented:
Thanks janmarini, Crystal Decision did forward me an sample application that doesn't seems to work in my machine (VS 2003 + VS 2005 + CRXIR2). if you need that sample application, pls let me know.

Dylan
0
 
dylanyeeAuthor Commented:
Latest Update.

I managed to get the Crystal Report XI R2 working both in my VS.NET 2003 & VS.NET 2005 that installed together in my pc. I simply uninstall the existing CR XI and reinstall again, and it solved the problem.

I think I know what's went wrong previously. I installed CR9 Designer after CR XI R2 is installed (for some reason, I still prefer to design the report in lower version). It seems that even thought I didn't choose to install CR9's development component for .net, it still override some of the important file for CR XI R2 which makes the .net compiler didn't work properly for XI R2.

So... the moral of the story is...
- Crystal Decision's customer support was given me a wrong information. The fact is, VS.NET 2003 & VS.NET 2005 could be install together in the same machine, CR XI R2 could works in both version together.
- CR XI or CR XI R2 should be install at last, never ever play around with lower version of CR (even install only the designer). If you want to do so, please install whatever lower version first then install CR XI at last.

I think I won't refund this thread, it might be help for some other users that experience the same problem. I will reward the points to all people that involved in this thread. Thanks everybody for your time~

Dylan
0
 
mlmccCommented:
Glad i could help

mlmcc
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now