Connecting Crystal Reports to DB2

P

Peter

C# .NET 2.0 - Crystal Reports XI

I am trying to connect Crystal Report to DB2 database from my C#
application. After I run the connection info code and try to export the
report I get

{"Database logon failed."} System.Exception
{CrystalDecisions.CrystalReports.Engine.LogOnException}


I am using the following code to connect:

Database crDatabase;
Tables crTables;
TableLogOnInfo crTableLogOnInfo;
ReportDocument crSubreportDocument;
Sections crSections;
SubreportObject crSubreportObject;
ReportObjects crReportObjects;

ConnectionInfo crConnectioninfo = new ConnectionInfo();

crConnectioninfo.ServerName = "DNS=MyDB2Server"; // or this
crConnectioninfo.ServerName = "MyDB2Server";
crConnectioninfo.UserID = "TestUser";
crConnectioninfo.Password = "TestPassword";
crConnectioninfo.DatabaseName = "MyDB2Database";

//set up the database and tables objects to refer to the current report
crDatabase = cr.Database;
crTables = crDatabase.Tables;

//loop through all the tables and pass in the connection info
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectioninfo;

crTable.ApplyLogOnInfo(crTableLogOnInfo);
}


I can connect with no problem when I am using CrystalReports IDE or when I
test my ODBC connection.

Does anyone know what values / format I have to specify to crConnectioninfo
or how to connect Crystal Report to DB2 from C# application?


Thank You


Peter
 
O

Octavio Hernandez

Hi Peter,

Have you tried using the ReportDocument.SetDatabaseLogon() method?

Regards - Octavio
 
Y

Yuan Ren[MSFT]

Hi Peter,

Thanks for posting!

For the current issue, I'm sorry that Microsoft only supports the setup
issue of the Crystal Report, other supports will be provide by Crystal
Decisions. The KB article shows more details as below:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;317789

In addition, I find an article from Crystal Decisions demonstrates how to
connect the database at runtime in VB.NET:
http://support.businessobjects.com/library/kbase/articles/c2010371.asp

I hope this will be helpful. I appreciate your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 

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