<p>Eg.</p>

<pre><code>ConnectionDetails cd = new ConnectionDetails ();
cd.ProviderName = "System.Data.OleDb";
cd.DataSource = "serverAddress";
cd.Catalog = "database";
cd.UserId = "userId";
cd.Password = "password";

string connectionString = cs.CreateConnectionString();
// Should return:
// "Provider=SQLOLEDB;Data Source=serverAddress;Initial Catalog=database;User Id=userId;Password=password;"
</code></pre>

<p>I'd write my own class but I'm not sure how to retrieve a connection string provider property (SQLOLEDB in this example) programmatically from an invariant db provider name (System.Data.OleDb).</p>

<p>Edit:</p>

<p>You can do a</p>

<pre><code>DbProviderFactories.GetFactory("System.Data.OleDB").CreateConnectionStringBuilder()
</code></pre>

<p>But the DBConnectionStringBuilder that is returned still doesn't know it's connection string provider property, even though in this case it the derived class has a "Provider" property.</p>

The closest thing I know of is
DbConnectionStringBuilder
.
Because the properties required by different providers vary, it uses an associative array (name value collection) rather than fixed properties.
So your example would look like
```
```
DbConnectionStringBuilder csb = new DbConnectionStringBuilder();
csb["ProviderName"] = "System.Data.OleDb";
csb["DataSource"] = "serverAddress";
csb["Catalog"] = "database";
csb["UserId"] = "userId";
csb["Password"] = "password";

string connectionString = csb.ConnectionString;
```
```