Last post Dec 08, 2015 10:12 PM by Lannie
Member
135 Points
401 Posts
Dec 08, 2015 02:17 PM|nvielbig|LINK
I have a helper class in an external library which takes in an OracleConnection and returns whether it is a Production, User or Test database.
Basically I do
OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
then
string environmentName = ApplicationEnvironment.GetEnvironment(conn).ToString();
Since I am never opening the connection, can anyone confirm that this is not something to be concerned about?
All-Star
48530 Points
18075 Posts
Dec 08, 2015 02:31 PM|PatriceSc|LINK
Hi,
Shouldn't but as a best practice just dispose the connection once you are done with it as for all disposable classes. Not sure what you are doing but if this is to check its connection string then you likely don't need anyway to create a connection.
Contributor
3462 Points
1341 Posts
Dec 08, 2015 10:12 PM|Lannie|LINK
depends on operational tempo and number of users.
small office app with user requesting a select here, insert there, update this,
and open and close not a problem
ramp that up to thousands of users coming at you with all kinds of requests
then staying open and adding things like connection pooling become more important
Member
135 Points
401 Posts
Is there a negative to creating a new OracleConnection, but not opening it?
Dec 08, 2015 02:17 PM|nvielbig|LINK
I have a helper class in an external library which takes in an OracleConnection and returns whether it is a Production, User or Test database.
Basically I do
then
Since I am never opening the connection, can anyone confirm that this is not something to be concerned about?
All-Star
48530 Points
18075 Posts
Re: Is there a negative to creating a new OracleConnection, but not opening it?
Dec 08, 2015 02:31 PM|PatriceSc|LINK
Hi,
Shouldn't but as a best practice just dispose the connection once you are done with it as for all disposable classes. Not sure what you are doing but if this is to check its connection string then you likely don't need anyway to create a connection.
Contributor
3462 Points
1341 Posts
Re: Is there a negative to creating a new OracleConnection, but not opening it?
Dec 08, 2015 10:12 PM|Lannie|LINK
depends on operational tempo and number of users.
small office app with user requesting a select here, insert there, update this,
and open and close not a problem
ramp that up to thousands of users coming at you with all kinds of requests
then staying open and adding things like connection pooling become more important