cancel
Showing results for 
Search instead for 
Did you mean: 

ApplyLogOnInfo, reverts back (Crystal Reports 2008)

Former Member
0 Kudos

Crystal Reports 2008 ver. 12.0.0.683(sp0)

Visual studio 2005 (vb)

SQL2005z & Oracle (db)

The problem is that when the following line is executed, the database name and all information reverts back to the original information (database name,etc) . (when i try to change connection SQL to Oracle db, and Oracle to SQL).

crTable.ApplyLogOnInfo(crTableLogOnInfo)

Code:

Dim crTableLogOnInfo As New TableLogOnInfo

Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo = New

CrystalDecisions.Shared.ConnectionInfo()

...

With crConnectionInfo

Select Case intProvider

Case databaseProvider.sqlServer

.ServerName = "server"

.DatabaseName = "DB"

.UserID = "sa"

.Password = ""

Case databaseProvider.Oracle

.LogonProperties.Clear()

.Attributes.Collection.Clear()

'setup the attributes for the connection

dbAttributes.Collection.Set("Server", "ORCL")

dbAttributes.Collection.Set("Trusted_Connection", False)

.ServerName = "ORCL"

.DatabaseName = ""

.UserID = "us"

.Password = "pwd"

.Attributes.Collection.Set("Database DLL", "crdb_oracle.dll")

.Attributes.Collection.Set("QE_DatabaseName", "")

'.Attributes.Collection.Set("QE_DatabaseType", "Servidor de Oracle")

.Attributes.Collection.Set("QE_SQLDB", True)

.Attributes.Collection.Set("SSO Enabled", False)

.Attributes.Collection.Set("QE_LogonProperties", dbAttributes)

.LogonProperties = dbAttributes.Collection

.Type = CrystalDecisions.Shared.ConnectionInfoType.CRQE

End Select

End With

...

..

*For Each crTable In crTables

crTableLogOnInfo = crTable.LogOnInfo

crTableLogOnInfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crTableLogOnInfo)

next*

Don't return error, ApplyLogOnInfo.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, Ismael;

Try changing your code a bit. The following is from one of our samples for connecting to Oracle:

CrReportDocument = New OracleReport()

'Create the Conection Info object to hold the logon information for the report

crConnectionInfo = New ConnectionInfo()

'Populate the ConnectionInfo Objects Properties with the appropriate values for

'the ServerName, User ID, Password and DatabaseName. However, since Oracle

'works on Schemas, Crystal Reports does not recognize or store a DatabaseName.

'Therefore, the DatabaseName property must be set to a BLANK string.

'If the connection is using ODBC, make sure to use the System DSN name as the ServerName

With crConnectionInfo

.DatabaseName = ""

.Password = "mypassword"

.ServerName = "Server1"

.UserID = "myuser"

End With

'Set the CrDatabase Object to the Report's Database

crDatabase = CrReportDocument.Database

'Set the CrTables object to the Tables collection of the Report's dDtabase

crTables = crDatabase.Tables

'Loop through each Table object in the Tables collection and apply the logon info

'specified ealier. Note this sample only has one table so the loop will only execute once

For Each crTable In crTables

crTableLogOnInfo = crTable.LogOnInfo

crTableLogOnInfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crTableLogOnInfo)

Next

Regards,

Jonathan

Former Member
0 Kudos

Thanks Jonathan.

Sorry ...I can't find OracleReport()

CrystalDecisions..library?

On Oracle connection (now), I use the DatabaseName property on BLANK string.

The information reverts back.

I use : ApplyLogOnInfo and crConnectionInfo, like your example.

Code :

dbAttributes = New CrystalDecisions.Shared.DbConnectionAttributes

dbAttributes.Collection.Set("Server", "ORCL")

dbAttributes.Collection.Set("Trusted_Connection", "False")

'setup the connection

crConnectionInfo.DatabaseName = ""

crConnectionInfo.ServerName = "ORCL"

crConnectionInfo.UserID = "imesd"

crConnectionInfo.Password = "imesd"

crConnectionInfo.Attributes.Collection.Set("Database DLL", "crdb_oracle.dll")

crConnectionInfo.Attributes.Collection.Set("QE_DatabaseName", "")

'crConnectionInfo.Attributes.Collection.Set("QE_DatabaseType", "Servidor Oracle")

crConnectionInfo.Attributes.Collection.Set("QE_LogonProperties", dbAttributes)

crConnectionInfo.Attributes.Collection.Set("QE_ServerDescription", "ORCL")

crConnectionInfo.Attributes.Collection.Set("QE_SQLDB", "True")

crConnectionInfo.Attributes.Collection.Set("SSO Enabled", "False")

.Type = CrystalDecisions.Shared.ConnectionInfoType.CRQE

crConnectionInfo.LogonProperties = dbAttributes.Collection

.

.

.

For Each crTable In crTables

crTableLogOnInfo = crTable.LogOnInfo

crTableLogOnInfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crTableLogOnInfo)

Next

Another alternative¿?

Regards

Answers (1)

Answers (1)

Former Member
0 Kudos

I've looped through the IConnection objects and set their connection information BEFORE applying log on info to the tables and had limited success.

Do this....

//foreach (CrystalDecisions.Shared.IConnectionInfo connection in document.DataSourceConnections)

//{

// connection.SetConnection(strServer, strDatabase, bIntegratedSecurity);

// connection.SetLogon(strUserId, strPassword);

//}

But there is no guarantee that it'll work.