Search The Blog
About this site

@RoyOsherove

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

from 5whys.com
Twitter: @RoyOsherove
My Book: The Art of Unit Testing
Latest Posts
« Disabling Connection Pooling | Main | More About Processes »
Sunday
Jun222003

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

PrintView Printer Friendly Version

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>