linux mania

অগাষ্ট 18, 2006

change database runtime in crystal report

যার অধীনে আছে: vs .net — pipasharto @ 1:11 pm

if we want to change database at run time, call the following function in just after initializecomponent() in constructor or in load method
private void ConfigureResultCrystalReports()
{
//crystalReportViewer1.SelectionFormula = selectFormula;
resultReport rpt = new resultReport();
rpt.RecordSelectionFormula = selectFormula;

//TextObject txt = (TextObject)rpt.ReportDefinition.ReportObjects["txtAtt"];
//txt.Text = attendanceReport;

ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = Application.StartupPath + @”\..\..\protisruti.mdb”;
connectionInfo.UserID = “admin”;
connectionInfo.Password = “dudukhai”;
SetDBLogonForReport(connectionInfo, rpt);

crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.Zoom(1);

}

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);

}

}

:)

অগাষ্ট 10, 2006

dynamically change crystal reports text

যার অধীনে আছে: vs .net — pipasharto @ 4:50 am

i searched a lot in the internet and finally found the solution, crystal report are slightly modified in the new .net 2005. the key idea is all the crystal report’s reportObjects are accessible. like if you have a text object in your report, its content can be changed on the fly. the code is

TextObject txt;

txt = (TextObject)rpt.ReportDefinition.ReportObjects["Text6"];//Text6 is the name of the textobject u wanna change

txt.Text=”attendance is “+9+”\n\njjj”; //:( the newlines not working yet , i dont know why

shahrear

Blog at WordPress.com.