TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
CHAITANYA KIRAN KASANI
NA
335
133.2k
How to Display Multiple DataTables Data in one CrystalReport
Jan 5 2015 5:04 AM
I have 2 DataTables one is Created From Data Entered In TextBoxes and Another DataTable Is Created From Database Sql Server. Now I Have to Show Both The DataTables Data In Single Crystal Report.
I Had Written Below Code,But It Is Showing Empty Crystal Report :
private void btnViewCrystal_Click(object sender, EventArgs e)
{
EmployeeDataSet ds = new EmployeeDataSet();
// Create First DataTable
DataTable t = ds.Tables.Add("EmpDetails");
t.Columns.Add("EmpNo", Type.GetType("System.Int32"));
t.Columns.Add("EmpName", Type.GetType("System.String"));
t.Columns.Add("DateOfBirth", Type.GetType("System.String"));
t.Columns.Add("Address", Type.GetType("System.String"));
t.Columns.Add("Country", Type.GetType("System.String"));
DataRow r;
r = t.NewRow();
r["EmpNo"] = txtEmpNo.Text;
r["EmpName "] = txtName.Text;
r["DateOfBirth"] = txtDay.Text + " /" + txtMonth.Text + " /" + txtYear.Text;
r["Address"] = txtAddress.Text;
r["Country"] = txtCountry.Text;
t.Rows.Add(r);
// Create Second DataTable
OleDbConnection cn = new OleDbConnection(ConfigurationManager.ConnectionStrings["Name_Correction.Properties.Settings.NameCorrectionConnectionString"].ConnectionString);
cn.Open();
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
DataTable dt = new DataTable();
cmd.Connection = cn;
cmd.CommandText = "select * from tblDepartment Where DeptNo=@DeptNo";
cmd.Parameters.Add("DeptNo", OleDbType.Integer).Value = int.Parse(txtDeptNo.Text);
da.SelectCommand = cmd;
dt.Clear();
da.Fill(dt);
ds.Tables.Add(dt);
//To Show The CrystalReport1 In CrystalReportViewer
CrystalReport1 objRpt = new CrystalReport1();
objRpt.SetDataSource(ds);
crystalReportViewer1.ReportSource = objRpt;
crystalReportViewer1.Refresh();
}
Reply
Answers (
1
)
Insert Statement Error
add property to css class by using css classname in c#