Visual Studio 2008 Reporting Wizard / DataSet Wizard borked ! RRS feed

  • General discussion

  • OK, so I've been struggling with the reporting wizard for a couple of days now, and I finally realized my problems were not of my own making.  This is usually the conclusion I come to, although recently, with the last few toolchain releases from Microsoft, I am finding my myself arriving at this conclusion far more rapidly.

    Here's a little test for you.

    Create a Windows Forms project
    In the project explorer, right click on the project then....
    Add -> New Item
    In  the categories panel, select Data
    In the Templates panel select DataSet
    In the DataSet Designer Window, click the highlighted word 'Toolbox'
    Click on the TableAdapter, then click into the DataSet Designer window.
    Populate a valid connection string, then click 'Next >'
    Ensure 'Use SQL statements' is selected., click 'Next >'
    Enter this SQL query into the text box:

            count(name) as 'Count', xtype
        group by

    then click 'Next >'

    Ensure 'Fill a DataTable'  and 'Return a DataTable' are checked and the Method Names are populated with 'Fill' and 'GetData'  respectively.
    Click 'Next >
    Verify that the the four 'details' have a tick next to them
    Click 'Finish'

    Now, right click on the TableAdapter in the designer, and select 'Preview Data', then click the 'Preview' button in the middle of the dialog box.   You should see two columns, and about a dozen rows (the actual results may depend upon your database configuration).  Now, close the data preview dialog box.

    At this stage we have a valid DataSet configured.

    Now, to build the report.

    Right click your project in the Project Explorer.
    Select "Add" -> "New Item"
    In  the categories panel, select Reporting
    In the Templates panel select Report  (this is the Microsoft supplied report template)
    then click 'Add'
    You should now be in the report designer.
    From the Toolbox panel, click 'Chart'
    Now, click on the design surface, and the chart shoudl appear.
    From DataSources panel expand the DataSet,
    select 'xtype' and drop it into the series 'pad' on the Chart
    select 'Count'' and drop it into the data 'pad' on the Chart

    Save all, and close all project document windows.
    Now edit your main form by double clicking it from the Solution Explorer
    From the toolbox, select MicrosoftReportViewer, and drop it onto your main form.
    The 'Report Viewer Tasks' window pops up
    Select your report from the 'Choose Report' drop down list box
    Then select 'Dock in parent container' (or equivalent)

    Now, all we have to do is load the data

    double click the reportviewer control, this should generate the Load event handler for the reqport viewer object
    In the load handler
    you should only need to add code which looks something like this  (assuming you haven't renamed any of the wizard generated objects)


    Now run your app, you should see a nice little chart showing you some useless information about the sysobjects table.

    At this stage we have done nothing fancy, just used the standard tools for generating a report.

    Now, close down your app, and add a new table adapter to your dataset.  give it another query (or even the same query if you like), add another chart to your report in the report designer, and select the data elements from your new table adapter.  So far so good, eh !

    Now the fun begins.  You need to fill the new DataTable with the data from the new TableAdapter, so you go to your reportViewer1_Load function, and try to add this line:


    and you notice that intellisense can't find your new table adapter, or your new data table.

    OK, fine the Wizard has somehow made some minor mistakes, but you can try to deal with them.  You take a look at the file which defines the original table adapter, and you can clearly see that the new adapter is also present.  After struggling for hours, you will be forgiven for getting disgusted and starting all over again, but this time, configuring both table adapters, then both reports, only to see it all magically work again.

    At this point you shake your head, and decide there's a very good reason Microsoft is losing market share.

    You see, you were supposed to delete the reportviewer object from your form, and re-add it, using the *new*  (even though you know it's only been modified) report definiton file.    Why, oh why doesn't this file get re-read when it changes ? !  Why don't you get warned - at a minimum - or prompted to take some kind of action when it changes ?  Why isn't this totally unhelpful behaviour documented in huge letters somewhere, anywhere ?

    Wednesday, August 6, 2008 10:30 AM