T
Thad
I'm new to C# and I was trying to create a Crystal Report. I've
designed a simple report and I've used several methods for attaching
fields to the report at design time. I've used a DataSet that I've
created by add new item, and I've used the add command and used an
actual SQL statement, and I've used the OLEDB ADO and connected to my
database (Access) tables directly.
I have code that will create a query, use that query with an Adapter
and connection, and return a DataSet.
When I call the Report.SetDataSource(FunctionReturnDataSet());
And then call the report viewer the data that is displayed doesn't
change from the design time data that was set up. It's almost as if
the new dataset I loaded with the SetDataSource, isn't even
recognized.
I've looked through several help sources, and I have my code exactly
like they had it, and I still don't get the data in the report that
should be comming over from the query that creates the new data set.
Below is the source I'm working with, thanks in advance for any time
and/or effort to answer this question.
Source Code:
//Set Rpt SQL, creates a SQL statement based on items selected in list
boxes
private void btnReport_Click(object sender, System.EventArgs e)
{
PeriodicCI rptPrdCI = new PeriodicCI();
TransporterData dataTrans = new TransporterData();
frmReportView rptView = new frmReportView();
try
{
dataTrans.setConnection();
rptPrdCI.SetDataSource (dataTrans.GetPrdCIDataSet(SetRptSQL()));
rptView.crView.ReportSource = rptPrdCI;
dataTrans.closeConnection();
rptView.Show();
}
catch (Exception eError)
{
MessageBox.Show((eError.Message), "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
public DataSet GetPrdCIDataSet(string sSQL)
{
OleDbDataAdapter daTmp = new OleDbDataAdapter();
DataSet dsReturn = new DataSet("PrdRptCI");
try
{
odedbTransporterComm.CommandText = sSQL;
daTmp.SelectCommand = odedbTransporterComm;
daTmp.Fill(dsReturn);
}
catch (Exception e)
{
MessageBox.Show((e.Message), "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
return dsReturn;
}
designed a simple report and I've used several methods for attaching
fields to the report at design time. I've used a DataSet that I've
created by add new item, and I've used the add command and used an
actual SQL statement, and I've used the OLEDB ADO and connected to my
database (Access) tables directly.
I have code that will create a query, use that query with an Adapter
and connection, and return a DataSet.
When I call the Report.SetDataSource(FunctionReturnDataSet());
And then call the report viewer the data that is displayed doesn't
change from the design time data that was set up. It's almost as if
the new dataset I loaded with the SetDataSource, isn't even
recognized.
I've looked through several help sources, and I have my code exactly
like they had it, and I still don't get the data in the report that
should be comming over from the query that creates the new data set.
Below is the source I'm working with, thanks in advance for any time
and/or effort to answer this question.
Source Code:
//Set Rpt SQL, creates a SQL statement based on items selected in list
boxes
private void btnReport_Click(object sender, System.EventArgs e)
{
PeriodicCI rptPrdCI = new PeriodicCI();
TransporterData dataTrans = new TransporterData();
frmReportView rptView = new frmReportView();
try
{
dataTrans.setConnection();
rptPrdCI.SetDataSource (dataTrans.GetPrdCIDataSet(SetRptSQL()));
rptView.crView.ReportSource = rptPrdCI;
dataTrans.closeConnection();
rptView.Show();
}
catch (Exception eError)
{
MessageBox.Show((eError.Message), "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
public DataSet GetPrdCIDataSet(string sSQL)
{
OleDbDataAdapter daTmp = new OleDbDataAdapter();
DataSet dsReturn = new DataSet("PrdRptCI");
try
{
odedbTransporterComm.CommandText = sSQL;
daTmp.SelectCommand = odedbTransporterComm;
daTmp.Fill(dsReturn);
}
catch (Exception e)
{
MessageBox.Show((e.Message), "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
return dsReturn;
}