views:

340

answers:

1

Hi All,

Disclaimer: I am not he most Crytal-y person in the world, so bear with me.

Technology: Visual Studio 2008, with the (free) Crystal Reports that comes with it.

Problem:

I have an existing (simple) report that uses an "ADO.NET DataSet" for its fields. I want to create a very similar report (layout/most of it pretty much the same), except that I need an additional field from a table that the original report doesn't have (there's some other modifications, but those don't give me issues). We'll call the original solution/project Foo.

OK, so I get down and dirty.

I take the Foo folder, copy it, and rename it to Bar.

I, of course, rename the sln to Bar.sln. I rename the .csproj to Bar.csproj.

I open these files (and others) and 'Find/replace' Foo references to Bar references.

That was easy (and quick). I open up the solution and everything is fine. I'm running the old report under the new Bar solution. There are no references to Foo anywhere (or so I think).

Now, time to modify the report.

First, I go to my DataSet1.xsd and add my new table and link it.

Next, I open up the .rpt file and go to the 'Database Expert'.

Database Expert opens and I have the two tabs (Data, Links). On the Data tab, for Selected Tables, I see DataSet1 and my tables. Excellent, I just need to add my new table. Wait, but if you right click on DataSet1 (under Selected Tables, the treeview), and select Properties, you see 'Foo.DataSet1' for Class Name.

WTF! I thought I replaced all references. I think the class name reference is tucked away in the .rpt binary somewhere. I really want this to point to Bar.DataSet1, not Foo.DataSet1.

How can I do that easily?

On the Data tab, on the left side (under ADO.NET DataSets), I do see Bar.DataSet1, with my new table. If I add over that one table to the 'Selected Tables' side, I now have two DataSets on the 'Selected Tables' side. If I remove the 'Foo' DataSet (hoping to just swap it out with the correct dataset - which has all the same tables/fields), I get the:

Remove All Tables MessageBox.
The report is using fields from one or more tables.  Continue?

Well, doing so, takes all my fields off of my report.

I just want to add one table! And I just want to reference the correct dataset! Help!!

+1  A: 

You can't edit a .rpt file directly - it's not a text-based format. So your Find/Replace will not work in this situation. What you'll have to do is use the Set Datasource Location option in the report designer and point it at the new dataset. This should pick up the field changes as well as the new table, but in case it doesn't you'll need to also use the Verify Database option.

CodeByMoonlight
And I had just came back here to answer my own question: Set Datasource Location is your friend. I think I jumped the gun a bit, I should have given myself a bit more time of just going through menus.Regardless, excellent and correct answer. In addition, you added the tid-bit about 'Verify Database'. Thanks a lot!
JustLooking