提示输入数据库连接字符串

发布于 2024-07-06 03:08:56 字数 372 浏览 14 评论 0原文

我想向用户提供数据库连接提示。 我可以构建自己的,但如果我可以使用其他人已经构建的东西(可能是 Windows 中内置的东西或 Internet 上提供的免费库),那就太好了。 有人知道如何在.Net 中做到这一点吗?

编辑:我发现了这个并认为它很有趣:在 WinForm 应用程序中显示连接字符串提示。 但这仅适用于 SQL Server 连接。

I would like to offer a database connection prompt to the user. I can build my own, but it would be nice if I can use something that somebody else has already built (maybe something built into Windows or a free library available on the Internet). Anybody know how to do this in .Net?

EDIT: I found this and thought it was interesting: Showing a Connection String prompt in a WinForm application. This only works for SQL Server connections though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

奢望 2024-07-13 03:08:57

我将 PropertyGrid 类 与 < a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnectionstringbuilder.aspx" rel="nofollow noreferrer">SqlConnectionStringBuilder 类 在单独的对话框中,并且 < a href="https://stackoverflow.com/questions/1103637/usercontrol-to-connect-to-a-sqlserver-database">对我来说效果非常好。

I combined the PropertyGrid Class with the SqlConnectionStringBuilder Class in a separate dialog and that worked really well for me.

不交电费瞎发啥光 2024-07-13 03:08:57

我能想到的唯一“内置”连接字符串功能是当您运行运行 SQL 脚本的 CMD 脚本(本质上是批处理文件)时出现的功能。 但是我不确定它是否是 Visual Studio 中内置的东西。

无论如何,制作一个非常简单。 如果您不希望用户能够输入直接的连接字符串,您可以将由四个文本框和一个复选框组成的一个组合在一起:

  • 服务器
  • 目录名称复选框
  • 用于集成安全性或 SQL 身份验证的
  • 用户名
  • 密码

相当简单,恕我直言。

The only "built in" connection string functionality that I could think of is the one that comes up when you run a CMD script (essentially a batch file) that runs SQL scripts. However I'm not sure if it's something built into Visual Studio.

It's really simple to make one anyway. If you don't want the user to be able to input a straight-out connection string, you can put together one made up of four textboxes and a checkbox:

  • Server
  • Catalog Name
  • checkbox for integrated security or SQL Authentication
  • Username
  • Password

Fairly trivial, IMHO.

尽揽少女心 2024-07-13 03:08:57

Microsoft 已在 Code Gallery 上发布了数据连接对话框的源代码。

这是一个 来自瑶海的博客文章,其中包含更多信息,这里是主页代码库上的数据连接对话框

Microsoft has released the source code for the data connection dialog on Code Gallery.

Here is an blog post from Yaohai with more info and here is the home of Data Connection Dialog on Code Gallery.

酒浓于脸红 2024-07-13 03:08:57

ADO.NET 有方便的 ConnectionStringBuilder,它可以构造和验证连接字符串。 这至少可以消除一个部分的繁重工作,允许您为输入创建一个简单的对话框。

ADO.NET has the handy ConnectionStringBuilder which will construct and validate a connection string. This would at least take the grunt work out of one part, allowing you to create a simple dialog box for the input.

初吻给了烟 2024-07-13 03:08:56

您可能想尝试使用SQL Server 管理对象。 这篇 MSDN 文章提供了一个很好的提示和连接到 SQL 服务器的示例。

You might want to try using SQL Server Management Objects. This MSDN article has a good sample for prompting and connecting to a SQL server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文