SAP Knowledge Base Article - Public

1206814 - How to change an Informix table location at runtime based on a native connection with Crystal Report .NET SDK

Symptom

Is it possible to change an Informix table location at runtime based on a native connection with Crystal Report .NET SDK?
 
It is indeed possible to change the Informix table location at runtime  based on a native connection with Crystal Report .NET SDK.
However when attending to do so through this code:

 

Tables tables = reportDocument.Database.Tables;

                                    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

                                    {

                                                TableLogOnInfo tableLogonInfo = table.LogOnInfo;

                                                tableLogonInfo.ConnectionInfo = connectionInfo;

                                                table.ApplyLogOnInfo(tableLogonInfo);

                                    }

This will result in either a "Logon failed error" or a "Database Connector error" error

Cause

The "Logon failed error" or  "Database Connector error" error is caused by the fact that the application cannot connect to the Informix server.

Resolution

To resolve the issue, edit the following registry key:
 
HKEY_LOCAL_MACHINE\SOFTWARE\Informix\SQLHOSTS, by adding the connection info of the informix server where you intend to change
the table location (remote server) as follows:

HOST=IPADDRESS or COMPUTERNAME
SERVICE=TCP PORT like 1527 for instance
PROTOCOL=olsoctcp

In your code, set the table location as follows:

 

Tables tables = reportDocument.Database.Tables;

                                    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

                                    {

                                                TableLogOnInfo tableLogonInfo = table.LogOnInfo;

                                                tableLogonInfo.ConnectionInfo = connectionInfo;

                                                table.ApplyLogOnInfo(tableLogonInfo);

                                           table.location ="DatabaseName:hostname:tablename";

                                    }

Using the informix server name instead of the hostname will fail.
You must use the hostname instead.

 

Refer to the sample code named "CS_Win_RDObjMod_DBLogon" for more information about changing the table location at runtime:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/CrystalReports_dotNET_SDK/crsdk_samples_aspx/data/crsdk_net_tutorials_115_en.zip

Keywords

Changing an Informix table location at runtime based on a native connection with Crystal Report .NET SDK , 9472972 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008