[译]连接字符串编辑器
By robot-v1.0
本文链接 https://www.kyfws.com/applications/connection-string-editor-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1994 个词 阅读量 0[译]连接字符串编辑器
原文地址:https://www.codeproject.com/Articles/5183/Connection-String-Editor
原文作者:Adam Byrne
译文由本站 robot-v1.0 翻译
前言
A tiny HTML application that will make your life easier
一个小型的HTML应用程序,将使您的生活更轻松
介绍(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)**连接字符串Editor.hta(Connection String Editor.hta)**双击文件即可运行到PC上的某个位置并运行它.(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?)
这个小应用程序是" HTML应用程序"(HTA)-基本上是一个HTML网页,可以在其自己的窗口中作为本地应用程序运行.如果您不相信我,则只需找到一些文本文件,将扩展名更改为.hta,然后双击它即可.(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.)
除了可以通过脚本实现用户界面的简便方法之外,您还可以使用HTA进行任何与本地VBScript相同的操作.有关HTA的更多信息,只需在Google上搜索" HTA应用程序",即可在那里加载.(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?)
这就是使该应用程序值得使用的一点,但一点也不难.连同MDAC所安装的所有东西(它们是数据库访问组件)一起,您得到的东西叫做" Microsoft OLE DB服务组件".实际的DLL是(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(oledb32.dll).(.)
名为" DataLinks"的对象隐藏在该对象中,看来该对象的唯一目的是编辑连接字符串.如果只有两种方法:(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:)**这包含一个ADO Connection对象,该对象将提示您编辑其连接字符串.(This takes in an ADO Connection object, whose connection string you will be prompted to edit.)
因此,要编辑连接字符串,只需创建一个ADO Connection对象,然后填充ConnectionString属性并将其作为参数传递给(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!)
此类" DataLinks"类对于在应用程序安装程序中用作自定义操作和东西非常有用.与设置DNS一样简单,但是您可以控制结果的去向.(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(microsoft.public.scripting)*Christoph Basedau的新闻组(在Google网上搜索" about:clipdata"以查找实际帖子).(newsgroup by Christoph Basedau (do a Google Group search for “about:clipdata” to find the actual post).)
结论(Conclusion)
这是我第一次尝试HTA,我认为它们非常酷.我知道HTML和其他内容不是很好,但是与文章相比,我花了更长的时间写这篇文章.这更多的是关于它的作用而不是它的作用,所以我希望您能从中有所用.干杯.(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.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
VBScript C++ WinXP Win2003 Windows Win2K Visual-Studio Dev 新闻 翻译