Problems with Crystal

  • Thread starter Thread starter Roger Boesch
  • Start date Start date
R

Roger Boesch

I try to set the connection parameters with the following code,
but the password is not set after a call to ApplyLogOnInfo.
What i am doing wrong ??

The call of TestConnectivity() brings: "Invalid Connection Parameter", but
the values are correct.




// Get the ConnectionInfo Object.
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo = m_document.Database.Tables[p_table].LogOnInfo;
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo = logOnInfo.ConnectionInfo;

// Set the Connection parameters.
connectionInfo.DatabaseName = p_database;
connectionInfo.ServerName = p_server;
connectionInfo.Password = p_password;
connectionInfo.UserID = p_user;
m_document.Database.Tables[p_table].ApplyLogOnInfo(logOnInfo);

// Test Connection
Table table = m_document.Database.Tables[p_table];
bool flag = table.TestConnectivity();
 
Hi Roger,

This is the code I'm using to do it:

TableLogOnInfos crTableLogonInfos = new TableLogOnInfos();

ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "127.0.0.1";
crConnectionInfo.DatabaseName = "CTP";
crConnectionInfo.UserID = "test";
crConnectionInfo.Password = "test";
foreach (CrystalDecisions.CrystalReports.Engine.Table table in
reportDocument1.Database.Tables)
{
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
crTableLogonInfo.TableName = table.Name;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
crTableLogonInfos.Add( crTableLogonInfo);
table.ApplyLogOnInfo( crTableLogonInfo);

}
CrystalReportViewer1.LogOnInfo = crTableLogonInfos;


AS you see you have to set the connection info for each table in the report.

Hope this help,
 
Back
Top