Array of db connections with string subscription

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
 
G

Guest

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.
 
M

Miha Markic

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.
 
J

John

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?
 
M

Miha Markic

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?
 
J

John

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?
 
M

Miha Markic

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top