Problems with Crystal

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roger Boesch

    #1

    Problems with Crystal

    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 TestConnectivit y() brings: "Invalid Connection Parameter", but
    the values are correct.




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

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

    // Test Connection
    Table table = m_document.Data base.Tables[p_table];
    bool flag = table.TestConne ctivity();


  • Ignacio Machin \( .NET/ C#  MVP \)

    #2
    Re: Problems with Crystal

    Hi Roger,

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

    TableLogOnInfos crTableLogonInf os = new TableLogOnInfos ();

    ConnectionInfo crConnectionInf o = new ConnectionInfo( );
    crConnectionInf o.ServerName = "127.0.0.1" ;
    crConnectionInf o.DatabaseName = "CTP";
    crConnectionInf o.UserID = "test";
    crConnectionInf o.Password = "test";
    foreach (CrystalDecisio ns.CrystalRepor ts.Engine.Table table in
    reportDocument1 .Database.Table s)
    {
    TableLogOnInfo crTableLogonInf o = new TableLogOnInfo( );
    crTableLogonInf o.TableName = table.Name;
    crTableLogonInf o.ConnectionInf o = crConnectionInf o;
    crTableLogonInf os.Add( crTableLogonInf o);
    table.ApplyLogO nInfo( crTableLogonInf o);

    }
    CrystalReportVi ewer1.LogOnInfo = crTableLogonInf os;


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

    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "Roger Boesch" <roger.boesch@y outs.com> wrote in message
    news:3f840fef$1 @news.swissonli ne.ch...[color=blue]
    > 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 TestConnectivit y() brings: "Invalid Connection Parameter", but
    > the values are correct.
    >
    >
    >
    >
    > // Get the ConnectionInfo Object.
    > TableLogOnInfo logOnInfo = new TableLogOnInfo( );
    > logOnInfo = m_document.Data base.Tables[p_table].LogOnInfo;
    > ConnectionInfo connectionInfo = new ConnectionInfo( );
    > connectionInfo = logOnInfo.Conne ctionInfo;
    >
    > // Set the Connection parameters.
    > connectionInfo. DatabaseName = p_database;
    > connectionInfo. ServerName = p_server;
    > connectionInfo. Password = p_password;
    > connectionInfo. UserID = p_user;
    > m_document.Data base.Tables[p_table].ApplyLogOnInfo (logOnInfo);
    >
    > // Test Connection
    > Table table = m_document.Data base.Tables[p_table];
    > bool flag = table.TestConne ctivity();
    >
    >[/color]


    Comment

    Working...