I'm developing a program in c# using winforms and devexpress that records data from up to 8 thermocouples and creates a new table for each new log, then inserts the data into the SQLite Table, and then creates a report based on the data in the new table. Everything works smoothly including creating the new table in SQLite and populating it with the data.
However I have encountered something that I knew was going to be challenging. I'm currently trying to set the XtraReport DataSource to a new SqlDataSource (I'll include in code below) and DataMember to a variable that I set as the name of the table. It opens the print dialog but doesnt show the report in it, and I am getting an error that says 'Invalid Data Member {table name}' (It shows me the value of the variable I set the member as).This is what I tried to do to set the Data Source:
private SqlDataSource BindToData()
{
SQLiteConnectionParameters connectionParameters =
new SQLiteConnectionParameters(UTDR_LOGS_DB.db", ""); //I included the whole path here but not including that on this post because this is not the problem
SqlDataSource ds = new SqlDataSource(connectionParameters);
CustomSqlQuery query = new CustomSqlQuery();
query.Name = "customQuery";
query.Sql = "SELECT * FROM " + tblName;
ds.Queries.Add(query);
ds.RebuildResultSchema();
return ds;
}
And here's how I create the report
private void btnCreateReport_Click(object sender, EventArgs e)
{
if (LogConfig.isLogging==true)
{
DialogResult = MessageBox.Show("Opening print tool will stop data logging. Proceed?", "Print Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (DialogResult == DialogResult.Yes)
{
LogConfig.isLogging = false;
XtraReport1 report = new XtraReport1();
report.DataSource = BindToData();
report.DataMember = tblName;
ReportPrintTool printTool = new ReportPrintTool(report);
printTool.ShowPreview();
}
}
}
I have the xrlabels on the xtra report set to the names of columns in the database because the column names are constant (not shown).