I am trying to modify the data that is available in the Web Designer from the code, and everything except the data itself is showing up. The purpose of this is so that the web designer can use information from our SQL Server even if it the user is not on our network.
The connection seems to be working correctly, and the tables and columns seem to be showing up correctly, but there does not appear to be any data in the columns.
If I add the data sources from within the designer the data correctly shows up, but not if I do so in the code (See images below)

(The correct information shows up in the dictionary)

(There should be data and a lot more pages of it. I know there is no data being found, because if I turn on "Print if Empty" property for the header, it prints, which means the databand is empty)
You can see the code I am using below. I am clearing the dictionary of all data previously associated with the report, then I am using StiReport.regData to get a DataSet, and then I am using StiReport.Dictionary.Databases.Add to set up the connection to the SQL Server. This is not working so far.
Code: Select all
private void InitializeDesigner()
{
// load the report
StiReport report = new StiReport();
report.Load(Server.MapPath("resources/Accessibility Test2.mrt"));
// clear initial settings
report.DataSources.Clear();
report.DataStore.Clear();
report.Dictionary.Databases.Clear();
//report.Dictionary.Load(Server.MapPath("resources/Dictionary AT2.dct")); // this works but not what we want
// add data to the datastore
report.RegData("DEMO", CreateDataSet()); // only seems to be fetching datasource information such as views and columns, but not the actual data
// add database connection(s) to the dictionary
string connectionName = "DEMO";
string connectionString = "Data Source=db; Initial Catalog=demo; " +
"Integrated Security=False; Persist Security Info=True; User ID=sa; Password=pass;";
StiSqlDatabase db = new StiSqlDatabase(connectionName, connectionString);
report.Dictionary.Databases.Add(db);
// synchronize data and schema
report.Dictionary.Synchronize();
// send the modified report to the designer
StiWebDesigner1.Design(report);
}
Code: Select all
private DataSet CreateDataSet()
{
// create an empty DataSet to store tables
System.Data.DataSet ds = new System.Data.DataSet();
try
{
// create connection string
string connectionString = "Data Source=db; Initial Catalog=demo; " +
"User Id=sa; Password=pass; " +
"Integrated Security=false;";
// create data adapter
SqlDataAdapter da = new SqlDataAdapter(
"SELECT * FROM C_APOC_ORDER_HEADER; " +
"SELECT * FROM C_APOC_PRODUCT_DETAIL; " +
"SELECT * FROM C_PackingSlip_SubRpt;",
connectionString);
// add table mappings
da.TableMappings.Add("Table", "C_APOC_ORDER_HEADER");
da.TableMappings.Add("Table1", "C_APOC_PRODUCT_DETAIL");
da.TableMappings.Add("Table2", "C_PackingSlip_SubRpt");
// fill the DataSet
da.Fill(ds);
}
catch (SqlException ex)
{
Console.WriteLine("SQL exception occurred: " + ex.Message);
}
return ds;
}
Thank you