junwebhead
Programmer
Hi everyone!
I have a problem in using crystal report.
I have the code below in my form where my crystal report viewer resides and I want to programatically change the location of the database in my cystal report before it loads. I find most part of this on MSDN but I couldn't get it working.
[tt]private void frmReport_Load(object sender, System.EventArgs e) {
CrystalReport1 myReport = new CrystalReport1();
TableLogOnInfo tbllogonInfo = new TableLogOnInfo();
[/tt]
//There is a compilation error here saying there is no overload that takes 1 arguments. But the Load() method has 3 overloads.[tt]
myReport.Load(mdiContainer.strReportLoc);[/tt]
//I try to delete the line above but I encountered a run-time error here. Saying "unable to find the report in the manifest resources."
[tt]
// Loop through every table in the report.
for (int i=0; i == myReport.Database.Tables.Count - 1; i++) {
// Set the connection information for the current table.
tbllogonInfo.ConnectionInfo.ServerName = MDIForm.strDBLoc;
tbllogonInfo.ConnectionInfo.DatabaseName = MDIForm.strDBLoc;
tbllogonInfo.ConnectionInfo.UserID = "";
tbllogonInfo.ConnectionInfo.Password = "";
myReport.Database.Tables
.ApplyLogOnInfo (tbllogonInfo);
}
crystalReportViewer1.ReportSource = mdiContainer.strReportLoc;
}[/tt]
What can I do to solve my problem? I'm using MSAccess 2000 as my database. Please help me. Thanks in advance.
Jun
I have a problem in using crystal report.
I have the code below in my form where my crystal report viewer resides and I want to programatically change the location of the database in my cystal report before it loads. I find most part of this on MSDN but I couldn't get it working.
[tt]private void frmReport_Load(object sender, System.EventArgs e) {
CrystalReport1 myReport = new CrystalReport1();
TableLogOnInfo tbllogonInfo = new TableLogOnInfo();
[/tt]
//There is a compilation error here saying there is no overload that takes 1 arguments. But the Load() method has 3 overloads.[tt]
myReport.Load(mdiContainer.strReportLoc);[/tt]
//I try to delete the line above but I encountered a run-time error here. Saying "unable to find the report in the manifest resources."
[tt]
// Loop through every table in the report.
for (int i=0; i == myReport.Database.Tables.Count - 1; i++) {
// Set the connection information for the current table.
tbllogonInfo.ConnectionInfo.ServerName = MDIForm.strDBLoc;
tbllogonInfo.ConnectionInfo.DatabaseName = MDIForm.strDBLoc;
tbllogonInfo.ConnectionInfo.UserID = "";
tbllogonInfo.ConnectionInfo.Password = "";
myReport.Database.Tables
Code:
[i]
}
crystalReportViewer1.ReportSource = mdiContainer.strReportLoc;
}[/tt]
What can I do to solve my problem? I'm using MSAccess 2000 as my database. Please help me. Thanks in advance.
Jun