Search code examples
c#sql-serverado.netoracle11gdbproviderfactories

DbProviderFactory Set ConnectionTimeout


Is there a possibility to change the connection timeout when we are using System.data.Common.DbProviderFactory?


Solution

  • Yes, check your connectionString to see if everything is fine to access the Database.

    A DBProviderFactory instance just return the abstrations of the System.Data.Common. The real type comes from your ado.net provider (SqlClient, OracleClient, etc.).

    When you do something like:

    IDbConnection connection = dbFactory.CreateConnection();
    connection.Open();
    

    The connection object is an abstration but the dbFactory.CreateConnection() will return a concrete type of OracleConnection or SqlConnection as your provider.