T
Terren
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.ApplyLogOnInfo(logOnInfo);
}
Any help would be appreciated
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.ApplyLogOnInfo(logOnInfo);
}
Any help would be appreciated