Hi !
You probably have to Add this line after the "For...{}" :
crRpt.VerifyDatabase();
I dont know exactly how it works with Access Db, but you may have to change
crRpt.Database.Tables[i].Location for each table. (With SQL server I had to
change it to "DATABASE_NAME.dbo.TABLE_NAME";
If you have Subreports in your reports, you have to change the Logoninfo for
each table from each sub-report, but you have to do it BEFORE changing the
logoninfo of the main report.
Steph.
"Terren" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I am trying to view a Crystal report (8.5) using the Crystalreports
> viewer for C#.net.
>
> I have a form and the view control on it. I am using the following
> code to try load the report as the database location might change from
> PC to PC. The report is using a Microsoft Access Database. There is no
> chance of me changing to Sql Server or another Database. I even remove
> the database password but it keeps asking for the password and
> username, even though I re-enter the corret information
>
> ReportDocument crRpt = new ReportDocument();
> crRpt.Load(Application.StartupPath + @"\Reports
> \MyRpt.rpt");
>
> TableLogOnInfo logOnInfo = new TableLogOnInfo();
>
> for (int i = 0; i < crRpt.Database.Tables.Count; i++)
> {
> // Set the connection information for the current
> table.
> logOnInfo.ConnectionInfo.AllowCustomConnection=true;
> logOnInfo.ConnectionInfo.Type =
> ConnectionInfoType.DBFile;
> logOnInfo.ConnectionInfo.IntegratedSecurity = false;
> logOnInfo.ConnectionInfo.ServerName = "MS Access
> Database";
> logOnInfo.ConnectionInfo.DatabaseName =
> Application.StartupPath + @"\myDatabase.mdb";
> logOnInfo.ConnectionInfo.UserID = "admin";
> logOnInfo.ConnectionInfo.Password = "password";
> crRpt.Database.Tables[i].ApplyLogOnInfo(logOnInfo);
> }
>
>
> Any help would be appreciated
>
|