Click here to Skip to main content
Click here to Skip to main content

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

Introduction

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

Conclusion

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.

License

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

Share

About the Author

Adam Byrne
Web Developer
Ireland Ireland
No Biography provided

Comments and Discussions

 
GeneralC# version of this is here Pinmemberelitecommerceserver24-Oct-03 9:36 
GeneralRe: C# version of this is here Pinmembermehafi2-Apr-05 0:48 
GeneralRe: C# version of this is here PinmemberVasudevan Deepak Kumar17-Aug-05 20:04 
GeneralConnection String Editor Pinmembercorputs17-Oct-03 9:06 
GeneralRe: Connection String Editor PinmemberAdam Byrne19-Oct-03 22:18 
GeneralExcuse me Pinmember=[ Abin ]=12-Oct-03 16:26 
GeneralRe: Excuse me PinmemberAdam Byrne14-Oct-03 3:49 
GeneralUse .udl file PinmemberIgor Vigdorchik10-Oct-03 7:11 
GeneralRe: Use .udl file, forgot to mention PinmemberIgor Vigdorchik10-Oct-03 10:55 
GeneralRe: Use .udl file, forgot to mention PinmemberAdam Byrne12-Oct-03 22:50 
GeneralRe: Use .udl file, forgot to mention PinmemberIgor Vigdorchik13-Oct-03 11:17 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 10 Oct 2003
Article Copyright 2003 by Adam Byrne
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid