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] > 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
>