Page 1 of 1

Setting Database and DataSource through Code - No Data returned

Posted: Wed Dec 10, 2008 9:53 am
by fuhrj
I want my end users to be able to design a report but not give them database connection information.

I set my code up when they click a button to launch the designer:

Code: Select all

StiReport report = new StiReport();

report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new StiSqlDatabase("LobbyCentral", Program.dbConnectionString));

if (reportFilename.Equals("")) {

   //New report - we need to add the DataSource 

    StiSqlSource mySQLDataSource = new StiSqlSource("LobbyCentral", "Table1", "Table1", "", false);

    report.Dictionary.DataSources.Add(mySQLDataSource);
    report.Dictionary.Synchronize();
    mySQLDataSource.SynchronizeColumns();
    report.Compile();
} else {

    //We are loading a report that has been designed, so assume the datasource is still there.
    report.Dictionary.Synchronize();
    report.DataSources[0].SynchronizeColumns();
    report.Compile();
    
}

report.Design(true);
The connection, database and everything appears and looks good. When you edit the datasource and add your sql query, the columns appear and the user can drag drop.

However, when you click the Preview tab, there is no data. If I right click on the DataSource and choose View Data, I can see the rows my query returns.

What am I missing in the code?

Setting Database and DataSource through Code - No Data returned

Posted: Wed Dec 10, 2008 6:14 pm
by Edward
Hi

Please make sure that NameInSource is "LobbyCentral" in the report template you have designed.

And what is the version of the report engine you work with? You could see it under Help - About menu item in the Designer.

Thank you.