PC Review


Reply
Thread Tools Rate Thread

Can't view Crystal Report

 
 
Terren
Guest
Posts: n/a
 
      20th Feb 2007
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

 
Reply With Quote
 
 
 
 
TheSteph
Guest
Posts: n/a
 
      21st Feb 2007
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
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report view / formatting problem mmcd79@tampabay.rr.com Microsoft VB .NET 0 12th Jun 2006 01:41 AM
Current/Active View Crystal Report henrycortezwu@gmail.com Microsoft VB .NET 0 31st Jul 2005 04:33 PM
How to change Crystal Report in VS.NET to Landscape view?? =?Utf-8?B?V2hpc2t5Um9tZW8=?= Microsoft Dot NET Framework Forms 2 21st Jun 2005 04:12 PM
View crystal Report in VB.net program Yummy Microsoft VB .NET 1 7th Mar 2005 01:50 AM
Crystal Reports .NET - can't view a report more than once Dean Sabella Microsoft VC .NET 0 20th Apr 2004 06:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:03 AM.