471,350 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Connecting Crystal Reports to DB2

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.LogOnExcep tion}
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
Feb 15 '06 #1
2 4377
Hi Peter,

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

Regards - Octavio
"Peter" <pc*****@nospam.nospam> escribió en el mensaje
news:%2***************@TK2MSFTNGP11.phx.gbl...
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.LogOnExcep tion}
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

Feb 15 '06 #2
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...b;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/l...s/c2010371.asp

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

Regards,

Yuan Ren [MSFT]
Microsoft Online Support

Feb 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Gheaci Maschl | last post: by
7 posts views Thread by p | last post: by
3 posts views Thread by Miro | last post: by
1 post views Thread by =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.