Groups | Blog | Home
all groups > c# > february 2006 >

c# : Connecting Crystal Reports to DB2


Peter
2/14/2006 9:16:42 PM
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

Octavio Hernandez
2/15/2006 12:00:00 AM
Hi Peter,

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

Regards - Octavio


"Peter" <pczurak@nospam.nospam> escribió en el mensaje
news:%23L7kB5dMGHA.668@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

v-yren NO[at]SPAM microsoft.com (
2/15/2006 12:00:00 AM
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
AddThis Social Bookmark Button