With .NET and Microsoft's dedication to documentation in the last couple of years I have really gotten spoiled. It is pretty rare that I actually dig into .dll's anymore trying to find some obscure functions and how to use them. These days if I can't find code examples using the Google search engine for something I want to do I will often just find another way around the problem, it just isn't worth spending time trying to dig into the lower levels for a very high level application. ( Google Chrome is one exception to this, thanks Google for digging for the extra speed, I love it. )
In this case I spent a few minutes searching for a connection string builder. I didn't find one so I started to role my own. After a couple of hours of that and realising just how many options there are I decided to try searching again. I knew one existed, Microsoft uses it in all their apps it seems, just had to find where it was and how to call it.
I found this guy:
who had essencially made a wrapper around what I was looking for, but there was no source code. However the fact he did it reinforced my certainty that I would find what I wanted.
Next I ran into Elisabeth who gave me the big break with source code and everything:
private string BuildConnectionString()
string strConnString = "";
object _con = null;
MSDASC.DataLinks _link = new MSDASC.DataLinks();
_con = _link.PromptNew();
if (_con == null) return string.Empty;
strConnString = ((ADODB.Connection)_con).ConnectionString;
I did end up having to go to her source ( glad she linked to it ) to get the pretty names of the .dll's that needed to be referenced: