Setting Database and DataSource through Code - No Data returned

Stimulsoft Reports.NET discussion
Post Reply
fuhrj
Posts: 120
Joined: Wed Jun 11, 2008 12:51 pm
Location: Lancaster, Ohio

Setting Database and DataSource through Code - No Data returned

Post 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?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Setting Database and DataSource through Code - No Data returned

Post 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.
Post Reply