How to get list of connection string keywords available in sqlclie

A

Armin Zingler

G

Guest

Hi Armin,

It seems that I can get the list from an instance of
System.Data.SqlClient.ConnectionStringBuilder. Not sure how to get it yet
since I'm not familiar of collections.
 
A

Armin Zingler

Peter said:
Hi Armin,

It seems that I can get the list from an instance of
System.Data.SqlClient.ConnectionStringBuilder. Not sure how to get
it yet since I'm not familiar of collections.


I didn't think of this class as being a collection like data source, more I
pointed to it because you can browse the available properties/keywords and
explicitly set them "early bound" without the need to fill the values into a
connection string. Though, I had a closer look at it, finding that it
implements IEnumerable, so you can use For Each:

Dim sb As New System.Data.SqlClient.SqlConnectionStringBuilder

sb.ConnectTimeout = 17
sb.DataSource = "test"

For Each pair As KeyValuePair(Of String, Object) In sb
'access the Key and Value propertis of object 'pair'
Next

May I ask why you need this?

Armin
 
G

Guest

Thanks Armin. I'm thinking about providing administrator of an application
the ability to set some of those keywords and then build the connection
string dynamcially. I can hardcode them instead of retrieving them
programmatically.
I wonder whether those keywords will expand automatically when the
underlying sqlclient provider support more keywords.

Using your sample coding will only fetch those keywords which have values
assigned. If I want to get all the keywords, I need to go thru the
keys.syncroot array and I don't think I can use KeyValuePair to loop thru
them.

Peter
 
A

Armin Zingler

Peter said:
Thanks Armin. I'm thinking about providing administrator of an
application the ability to set some of those keywords and then build
the connection string dynamcially. I can hardcode them instead of
retrieving them programmatically.
I wonder whether those keywords will expand automatically when the
underlying sqlclient provider support more keywords.

Using your sample coding will only fetch those keywords which have
values assigned. If I want to get all the keywords, I need to go
thru the keys.syncroot array and I don't think I can use
KeyValuePair to loop thru them.

Why don't you put all possible keywords into a list? Has to be done once
only.


Armin
 

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