locked
How to set connection tmeout propery to crystal report using C#.net dynamically RRS feed

  • Question

  • User1619792777 posted

    Hi dear friends,

      Is that possible to set the connection timeout property for crystal repor, if the crystal report takes too longer than expected then i need to show a timeout error, right now some reports taking more than 10 -12 minutes to execute even though the stored proc is executed in less than a minute, since there is lot a data and to create paging in crystal report it is taking time. How can i inculude timeout in crystal ConnectionInfo

    The below is the connection for the crystal report, its having all the connection info properties but no Connection Time out, how can i include connection time to the below code:

    CrystalDecisions.Shared.TableLogOnInfo tliCurrent;

     foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in
                    crDoc.Database.Tables)
                {

                   tbl.LogOnInfo.ConnectionInfo.IntegratedSecurity = false;

                    tliCurrent = tbl.LogOnInfo;
                    tliCurrent.ConnectionInfo.AllowCustomConnection = true;
                    tliCurrent.ConnectionInfo.IntegratedSecurity = false;
                    tliCurrent.ConnectionInfo.ServerName = "servername";
                    tliCurrent.ConnectionInfo.UserID = "sa";
                    tliCurrent.ConnectionInfo.Password = "password";
                    tliCurrent.ConnectionInfo.DatabaseName = "dbname";
                    //tliCurrent.ConnectionInfo.LogonProperties.Add(new NameValuePair2("Connection Timeout", 1)); // THIS IS NOT WORKING
                     tliCurrent.TableName = tbl.Name;
                     tbl.ApplyLogOnInfo(tliCurrent);

          }

    Monday, September 10, 2012 5:42 AM

Answers

  • User-578610739 posted

    Hi Siva,

    http://blog.dragonsoft.us/2009/06/23/expiration-of-crystalreport-viewer-pages-with-long-running-queries/

    time out is related the session. so anytime the process going to work, its timing start till the limitation we declare. we can change by iis or web.config.

    http://forums.asp.net/t/1283350.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 11, 2012 3:08 AM

All replies

  • User-578610739 posted

    Hi Siva,

    Are you check the same thing in sqlserver management studio? if there is no problem , then the same thing check with crystal report, check that preview showen with the same parameter value.

    tell me after checking.

    Tuesday, September 11, 2012 12:42 AM
  • User-578610739 posted

    Hi Siva,

    also check if you have other report, then the same problem comes or not? if yes, then your database is  not access in app.

    check the remote connection properties of sqlserver or firewall.

    Tuesday, September 11, 2012 12:44 AM
  • User1619792777 posted

    Hi Ajay,

      I am just looking for a code to set the connection timeout for crystal report, just like we set for asp.net apps in webconfig

    Like: "Connection Timeout", 1

                    tliCurrent.ConnectionInfo.UserID = "sa";
                    tliCurrent.ConnectionInfo.Password = "password";
                    tliCurrent.ConnectionInfo.DatabaseName = "dbname";

    The BELOW IS THE CODING I AM LOOKING FOR (Just a sample one this is not working)
                    tliCurrent.ConnectionInfo.LogonProperties.Add(new NameValuePair2("Connection Timeout", 1)); // THIS IS NOT WORKING
                  

    Tuesday, September 11, 2012 1:25 AM
  • User-578610739 posted

    Hi Siva,

    Sorry to say ,but you are going in wrong direction. you must worry about why time out comes, not set the timeout.

    Because if you set time out and the report comes after 10-12 min, still your boss will not appreciate or I can say it is not acceptable from client also.

    So don't set or code for any time out part. Just try to get faster data and show report as early as possible.

    check above instruction, you better judge why it is going wrong. check your end and still you have problem then reply

    Tuesday, September 11, 2012 1:51 AM
  • User1619792777 posted


    Hi Ajay,

     Thanks for the response, ok is that possible to set the timeout to cyrstal then if it is possible we will probably set to 25 minutes or it is upto my lead. I just want to know it is possible to set the timeout or not. If not possible then we are going to leave this research.

    This is my dynamic query for crystal connection [This is the most used code by all crystal developers].

    CrystalDecisions.Shared.TableLogOnInfo tliCurrent;

     foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in
                    crDoc.Database.Tables)
                {

                   tbl.LogOnInfo.ConnectionInfo.IntegratedSecurity = false;

                    tliCurrent = tbl.LogOnInfo;
                    tliCurrent.ConnectionInfo.AllowCustomConnection = true;
                    tliCurrent.ConnectionInfo.IntegratedSecurity = false;
                    tliCurrent.ConnectionInfo.ServerName = "servername";
                    tliCurrent.ConnectionInfo.UserID = "sa";
                    tliCurrent.ConnectionInfo.Password = "password";
                    tliCurrent.ConnectionInfo.DatabaseName = "dbname";
                    //tliCurrent.ConnectionInfo.LogonProperties.Add(new NameValuePair2("Connection Timeout", 1)); // THIS IS NOT WORKING
                     tliCurrent.TableName = tbl.Name;
                     tbl.ApplyLogOnInfo(tliCurrent);

          }

    Tuesday, September 11, 2012 2:37 AM
  • User-578610739 posted

    Hi Siva,

    http://blog.dragonsoft.us/2009/06/23/expiration-of-crystalreport-viewer-pages-with-long-running-queries/

    time out is related the session. so anytime the process going to work, its timing start till the limitation we declare. we can change by iis or web.config.

    http://forums.asp.net/t/1283350.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 11, 2012 3:08 AM
  • User-1300524625 posted

    I had the same problem. Crystal can be a nightmare sometimes...

    To set LogonProperties you have to do the following:

    for (int i = 0; i < crDoc.DataSourceConnections.Count; i++)
    {
        NameValuePairs2 lp = crDoc.DataSourceConnections[i].LogonProperties;
        lp.Set("Connection Timeout", "1");
        crDoc.DataSourceConnections[i].SetLogonProperties(lp);
    }
    Subreports subReports = crDoc.Subreports;
    for (int i = 0; i < subReports.Count; i++)
    {
        for (int j = 0; j < subReports[i].DataSourceConnections.Count; j++)
        {
            NameValuePairs2 lp = subReports[i].DataSourceConnections[j].LogonProperties;
            lp.Set("Connection Timeout", "1");
            subReports[i].DataSourceConnections[j].SetLogonProperties(lp);
        }
    }
    
    Wednesday, August 21, 2013 3:41 AM