locked
Connection Timeout question RRS feed

  • Question

  • Hi,

    I am trying to change default connection timeout by passing in the connection string the wanted value :

    "DSN=MSSQLEXPRESS_LOCAL;UID=;PWD=;Trusted_Connection=Yes;DATABASE=DBTest_V2B;Connection Timeout=42"

    Then when I look at ConnectionTimeout property inside my DBConnection the value is still the default one :

    public DbConnection Connection { get; set; }

    public virtual void Open()
            {
                if (Connection.State == ConnectionState.Closed)
                {
                    Connection.Open();
                }
            }

    What am I missing ?

     

     

     

    Wednesday, January 12, 2011 3:53 PM

Answers

  • Off hand, I'd say it's a problem with the particular connection type that you're using not supporting that peropty from the connection string.  What kind of connections (SqlClient, OleDb, etc) are you making?  
    -cd Mark the best replies as answers!
    • Marked as answer by Cookie Luo Wednesday, January 19, 2011 7:00 AM
    Thursday, January 13, 2011 9:55 PM
  • "DSN=MSSQLEXPRESS_LOCAL;UID=;PWD=;Trusted_Connection=Yes;DATABASE=DBTest_V2B;Connection Timeout=42"

    Hi

    This connection string has told us he is making a sqlclient connection.

     And code you privided has nothing to do with the previous one. Can you please provide some detailed code?


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Cookie Luo Wednesday, January 19, 2011 7:00 AM
    Friday, January 14, 2011 8:42 AM
  • Wow DSN.  I have not seen one of those used in a long long time.   Are DSN supported even with sqlclient?  I think they are only for odbc connections.

     

    Why dont you just change to the name of the machine instead.  DSN is old arcane stuff.

    • Marked as answer by Cookie Luo Wednesday, January 19, 2011 7:00 AM
    Saturday, January 15, 2011 5:11 AM

All replies

  • Please show a bit of code that demonstrates how you're instantiating your connection.


    -cd Mark the best replies as answers!
    Wednesday, January 12, 2011 10:50 PM
  • protected ConnectionFactory()
            {
                try
                {
                    _isConnectionRecycleEnabled = true;

                    DbProviderFactory factory = DbProviderFactories.GetFactory(ApplicationConfiguration.Instance.GetConfiguration("ConnectionType"));
                    if (factory == null)
                    {
                        return;
                    }

                    ConnectionName = ApplicationConfiguration.Instance.GetConfiguration("ConnectionName");

                    _connection = new DatabaseConnection();
                    _connectionString = ApplicationConfiguration.Instance.GetConfiguration("ConnectionString");
                    _connection.Factory = factory;
                    _connection.Connection = factory.CreateConnection();
                    _connection.Connection.ConnectionString = _connectionString;
                }
                catch (Exception)
                {
                    return;
                }
            }

    Thursday, January 13, 2011 1:03 PM
  • Off hand, I'd say it's a problem with the particular connection type that you're using not supporting that peropty from the connection string.  What kind of connections (SqlClient, OleDb, etc) are you making?  
    -cd Mark the best replies as answers!
    • Marked as answer by Cookie Luo Wednesday, January 19, 2011 7:00 AM
    Thursday, January 13, 2011 9:55 PM
  • "DSN=MSSQLEXPRESS_LOCAL;UID=;PWD=;Trusted_Connection=Yes;DATABASE=DBTest_V2B;Connection Timeout=42"

    Hi

    This connection string has told us he is making a sqlclient connection.

     And code you privided has nothing to do with the previous one. Can you please provide some detailed code?


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Cookie Luo Wednesday, January 19, 2011 7:00 AM
    Friday, January 14, 2011 8:42 AM
  • Wow DSN.  I have not seen one of those used in a long long time.   Are DSN supported even with sqlclient?  I think they are only for odbc connections.

     

    Why dont you just change to the name of the machine instead.  DSN is old arcane stuff.

    • Marked as answer by Cookie Luo Wednesday, January 19, 2011 7:00 AM
    Saturday, January 15, 2011 5:11 AM