How do create a report using code for different data sources
Posted: Sat Dec 03, 2011 6:39 am
Hi I written a code but it is throwing error.
{
connection.Open();
SqlDataAdapter adapter = null;
DataSet dataSet = new DataSet();
StiReport report1 = new StiReport();
string sql1 = "Select patient_id,last_name from patient where patient_id=175";// (192.168.0.101)
[Select patient_id,last_name from patient where patient_id=@patientID] // This is written in Design time for (192.168.0.100).
adapter = new SqlDataAdapter(sql1, connection);
adapter.Fill(dataSet);
string appDirectory = HttpContext.Current.Server.MapPath("~/");
report1.Load(appDirectory + "\\PatientTrail.mrt");
dataSet.Tables[0].TableName = "patients";
report1.DataSources.Clear();
report1.Dictionary.Databases.Clear();
report1.RegData("DataSource", dataSet.Tables["patients"]);
report1.Dictionary.Synchronize();
report1.Render(false); // HERE I GETTING THE ERROR.
StiWebViewer1.Report = report1;
StiWebViewer1.Visible = true;
}
I want to know how to design a report using local database server connection(192.168.0.100), later in the code I want to connect to some other database server connection(192.168.0.101).
Is it possible ?
Please tell me as early as possible.
For the above code the following error I'm getting.
THE NAME 'DataSource1' DOES NOT EXIST IN THE CURRENT CONTEXT.
{
connection.Open();
SqlDataAdapter adapter = null;
DataSet dataSet = new DataSet();
StiReport report1 = new StiReport();
string sql1 = "Select patient_id,last_name from patient where patient_id=175";// (192.168.0.101)
[Select patient_id,last_name from patient where patient_id=@patientID] // This is written in Design time for (192.168.0.100).
adapter = new SqlDataAdapter(sql1, connection);
adapter.Fill(dataSet);
string appDirectory = HttpContext.Current.Server.MapPath("~/");
report1.Load(appDirectory + "\\PatientTrail.mrt");
dataSet.Tables[0].TableName = "patients";
report1.DataSources.Clear();
report1.Dictionary.Databases.Clear();
report1.RegData("DataSource", dataSet.Tables["patients"]);
report1.Dictionary.Synchronize();
report1.Render(false); // HERE I GETTING THE ERROR.
StiWebViewer1.Report = report1;
StiWebViewer1.Visible = true;
}
I want to know how to design a report using local database server connection(192.168.0.100), later in the code I want to connect to some other database server connection(192.168.0.101).
Is it possible ?
Please tell me as early as possible.
For the above code the following error I'm getting.
THE NAME 'DataSource1' DOES NOT EXIST IN THE CURRENT CONTEXT.