Array of db connections with string subscription

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Can I have an array of type OleDb.OleDbConnection that has strings as
subscription values? The reason I need this is my app reads a configuration
file with db names and their locations and it then creates all connections
and if subscript is the db name as string then it is easy for the app to
figure out which db is which and to link it with other db settings in the
configuration file.

Thanks

Regards
 
Can I have an array of type OleDb.OleDbConnection that has strings as
subscription values? The reason I need this is my app reads a
configuration file with db names and their locations and it then
creates all connections and if subscript is the db name as string then
it is easy for the app to figure out which db is which and to link it
with other db settings in the configuration file.

You can store several connections in a hashtable. However, it is best to
open/close connections as you need them and not keep several connections
open.
 
You mean the value part? Sure, why not.
However, I would recommend, as stated in previous post, to avoid retaining
connections - that's the connection pool's job.
 
Thank. Could you tell ma how to declare a hashtable of type
OleDb.OleDbConnection with a string type subscript?

Thanks

regards


Miha Markic said:
You mean the value part? Sure, why not.
However, I would recommend, as stated in previous post, to avoid retaining
connections - that's the connection pool's job.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

John said:
Can hashtable be of type OleDb.OleDbConnection?
 
What .net version are you using?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

John said:
Thank. Could you tell ma how to declare a hashtable of type
OleDb.OleDbConnection with a string type subscript?

Thanks

regards


Miha Markic said:
You mean the value part? Sure, why not.
However, I would recommend, as stated in previous post, to avoid
retaining connections - that's the connection pool's job.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

John said:
Can hashtable be of type OleDb.OleDbConnection?
 
I am on vs2008, can use any.

Regards

Miha Markic said:
What .net version are you using?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

John said:
Thank. Could you tell ma how to declare a hashtable of type
OleDb.OleDbConnection with a string type subscript?

Thanks

regards


Miha Markic said:
You mean the value part? Sure, why not.
However, I would recommend, as stated in previous post, to avoid
retaining connections - that's the connection pool's job.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Can hashtable be of type OleDb.OleDbConnection?
 
You can use Dictionary<K,V> then, i.e.
Dictionary<string, OleDbConnection> dict = new Dictionary<string,
OleDbConnection>();
dict.Add("...", conn);

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

John said:
I am on vs2008, can use any.

Regards

Miha Markic said:
What .net version are you using?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

John said:
Thank. Could you tell ma how to declare a hashtable of type
OleDb.OleDbConnection with a string type subscript?

Thanks

regards


"Miha Markic" <miha at rthand com> wrote in message
You mean the value part? Sure, why not.
However, I would recommend, as stated in previous post, to avoid
retaining connections - that's the connection pool's job.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Can hashtable be of type OleDb.OleDbConnection?
 
Back
Top