Display Crystal Report with database logon ingo

D

deegee

hi,

I'm trying to display a simple crystal report from within a web
application but I keep getting prompted to enter login details for the
database (oracle). Entering the correct information manually displays
the report perfectly but there must be a way of passing the login
details automatically?? How do I do it? There is currently no code
in the page - I simply added a Crystal Report Viewer and set the report
as required.

I'm using VS 2005 and I'd appreciate any comments or example code!

Thanks.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I use this code in a 2003 solution.

TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();

ConnectionInfo crConnectionInfo = new ConnectionInfo();

crConnectionInfo.ServerName =
System.Configuration.ConfigurationSettings.AppSettings["Server"];
crConnectionInfo.DatabaseName =
System.Configuration.ConfigurationSettings.AppSettings["DataBase"] ;
crConnectionInfo.UserID =
System.Configuration.ConfigurationSettings.AppSettings["User"] ;
crConnectionInfo.Password =
System.Configuration.ConfigurationSettings.AppSettings["Password"] ;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in
reportDocument1.Database.Tables)
{
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
crTableLogonInfo.TableName = table.Name;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
crTableLogonInfos.Add( crTableLogonInfo);
table.ApplyLogOnInfo( crTableLogonInfo);

}
CrystalReportViewer1.LogOnInfo = crTableLogonInfos;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top