Setting Database and DataSource through Code - No Data returned
Posted: Wed Dec 10, 2008 9:53 am
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:
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?
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);
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?