Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Table Numbe error when setting Crystal datasource to datatable

Status
Not open for further replies.

lunchbox88

Programmer
Feb 17, 2004
208
US
I can set the datasource of a Crystal Report to a DataSet, and it works just fine. If I try to set it to a particular DataTable, I get the error "Invalid Table Number"

Any ideas why this would happen?
 
where exactly are you getting this error? designer, code, runtime, design time?

when you set the datasource at design time you need to select a dataset and then the tables within the dataset you want to use.

then at runtime populate these tables and pass the dataset to the report. if the report requires exactly 1 table you can pass that specific table to the report.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Runtime is when I get the error. In looking back, my question should have been:

If I set the datasource to a DataSet or DataTable, can I still access the ReportDocument.Database object? Or is that only populated when you actually connect to a DB?
 
Why would you need access to the Database object if you're using a dataset/table?

I have seen an error about authentication when binding a report to a datset with multiple tables. I believe the reason is the dataset contains tables that's haven't been populated/initialized, or aren't used in the report.

My experience with CR is limited, but what I have found is that a report with a dataset as the source should contain the exact number of tables/relations/fields that are required by the report.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I found my answer. Thanks for the replies!

What I was trying to do is "fake" dynamic reports as best as I can. What I was failing to do was build the report off of an XML schema of a dataset. I needed it to be generic enough that I could use a dataset generated from one of two databases. As long as they can fall in to the same schema (which they can), I can pass it whichever one is appropriate. This way, I can just create as many formula fields as there are potential fields, and set them to a value at runtime.

This allows the user to control which fields they want, and order the fields however they want. It will also allow them to report off of two separate databases (that hold roughly the same data...one is for quotes, and the other is for those quotes that have been booked).

Thanks again for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top