Click here to Skip to main content
13,291,690 members (59,830 online)
Click here to Skip to main content
Add your own
alternative version


50 bookmarked
Posted 9 Oct 2003

Connection String Editor

, 9 Oct 2003
Rate this:
Please Sign up or sign in to vote.
A tiny HTML application that will make your life easier


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

You may also be interested in...

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 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 10 Oct 2003
Article Copyright 2003 by Adam Byrne
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid