Tuesday, July 2, 2013

Set value in Text Object in Crystal report at Runtime in C#

Here is the Simple Code :-
===================

CrystalReport1 Obj = new CrysralReport1();

 //Set a Crystal Reports text object at runtime
 CrystalDecisions.CrystalReports.Engine.TextObject txtQuotationNum = ((CrystalDecisions.CrystalReports.Engine.TextObject)crQuotation.ReportDefinition.Sections["Section1"]
.ReportObjects["txtQuotation"]);  // "txtQuotation" is the TextObject name mention on Crystal Report Viewer.

  txtQuotationNum.Text = "bla bla bla...";
  crystalReportViewer1.ReportSource = crQuotation;

Monday, July 1, 2013

DataTable already belongs to another DataSet Exception

Exception Occure : DataTable already belongs to another DataSet Exception :-
--------------------------------------------------------------------------------



Like the other responses point out, the error you're seeing is because the DataTable you're attempting to add to a DataSet is already a part of a different DataSet.

One solution is to Copy the DataTable and assign the copy to the other DataSet.

dataTable dtCopy = datatable1.Copy();
ds.Tables.Add(dtCopy);
Your problem will solve.