Follow @RoyOsherove on Twitter

A Little Macro To Automate Creating Connection Strings

I've created a little macro that automatically creates a connection string and inserts it in your code. It pops up the infamous "Data Links" dialog for you, saving you, the poor programmer, from having to remember all those pesky little syntax details.... :)

No references needed for this. Thank god for CreateObject :)

Public Sub InsertConnectionString()

Dim links As Object = CreateObject("DataLinks")

Dim cn As Object = CreateObject("ADODB.Connection")

 

links.PromptEdit(cn)

If cn.connectionstring = "" Then Exit Sub

 

Dim sel As TextSelection = ActiveDocument().Selection

sel.Text = cn.connectionstring

End Sub

Now just add a shortcut for it and you're ready to roll...

Disabling Connection Pooling

More About Processes