Click here to Skip to main content
15,125,547 members
Articles / Programming Languages / VBScript
Posted 9 Oct 2003


51 bookmarked

Connection String Editor

Rate me:
Please Sign up or sign in to vote.
4.88/5 (21 votes)
9 Oct 20033 min read
A tiny HTML application that will make your life easier

Image 1


Have you ever had to create or change a connection string for one of your applications? It can be a very difficult thing to do, especially when on-site and/or you have no development environment handy. Well this should make your life a bit easier.

Using the Application

Just extract the file Connection String Editor.hta to somewhere on your PC and run it, by double clicking on the file.

You will be presented with a window containing a textbox and a couple of buttons.

  • Text Box: This is where your connection string goes.
  • Edit Button: Clicking this prompts for a new connection if the text box is empty. Otherwise it prompts you to edit the current connection string.
  • Copy Button: Clicking this copies the contents of the text box to the clipboard.

And that's just about all it does.

How Does It Work?

This little application is an "HTML Application" (HTA) - which is basically a HTML web page that runs as a local application in a window of its own. If you don't believe me, then just find some text file, change the extension to .hta, and double-click on it.

You can do anything with HTAs that you can with a local VBScript, except you get an easy way to implement a user-interface with your scripting. For more information on HTAs, just search for "HTA Application" on Google, there loads there.

But What About the Other Dialog That Comes Up?

That's the bit that makes this application worthwile, but it wasn't hard to do at all. Along with all the things that MDAC installs (they're the database access components), you get something called "Microsoft OLE DB Service Component". The actual DLL is oledb32.dll.

This object called "DataLinks" hides in there, and it seems the sole purpose of this object is to edit connection strings. If only has two methods:

  • PromptNew: This does exactly what it claims to, and returns the new connection string. As a string. Cool.
  • PromptEdit: This takes in an ADO Connection object, whose connection string you will be prompted to edit.

So to edit a connection string just create an ADO Connection object, populate the ConnectionString property and pass it as a parameter to a DataLinks object's PromptEdit method. Bob is everyone's uncle. Hurrah!

This "DataLinks" class can be a really useful one to use in your application installers as custom actions and stuff. As easy as setting up a DNS, but you can control where the result goes.

As for the copy to clipboard thing, well I take no credit for that sneaky bit of scripting. That method was posted to the microsoft.public.scripting newsgroup by Christoph Basedau (do a Google Group search for "about:clipdata" to find the actual post).


This is my first attempt at HTAs and I think they're pretty cool. I know the HTML and stuff isn't that nice, but it took me longer to write the article than the code. This is more about what it does than how it does it, so I hope yous get some use out of this. Cheers.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Adam Byrne
Web Developer
Ireland Ireland
No Biography provided

Comments and Discussions

GeneralC# version of this is here Pin
elitecommerceserver24-Oct-03 10:36
Memberelitecommerceserver24-Oct-03 10:36 
GeneralRe: C# version of this is here Pin
mehafi2-Apr-05 1:48
Membermehafi2-Apr-05 1:48 
GeneralRe: C# version of this is here Pin
Vasudevan Deepak Kumar17-Aug-05 21:04
MemberVasudevan Deepak Kumar17-Aug-05 21:04 
GeneralConnection String Editor Pin
corputs17-Oct-03 10:06
Membercorputs17-Oct-03 10:06 
GeneralRe: Connection String Editor Pin
Adam Byrne19-Oct-03 23:18
MemberAdam Byrne19-Oct-03 23:18 
GeneralExcuse me Pin
Abin12-Oct-03 17:26
MemberAbin12-Oct-03 17:26 
GeneralRe: Excuse me Pin
Adam Byrne14-Oct-03 4:49
MemberAdam Byrne14-Oct-03 4:49 
GeneralUse .udl file Pin
Igor Vigdorchik10-Oct-03 8:11
MemberIgor Vigdorchik10-Oct-03 8:11 
GeneralRe: Use .udl file, forgot to mention Pin
Igor Vigdorchik10-Oct-03 11:55
MemberIgor Vigdorchik10-Oct-03 11:55 
GeneralRe: Use .udl file, forgot to mention Pin
Adam Byrne12-Oct-03 23:50
MemberAdam Byrne12-Oct-03 23:50 
GeneralRe: Use .udl file, forgot to mention Pin
Igor Vigdorchik13-Oct-03 12:17
MemberIgor Vigdorchik13-Oct-03 12:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.