是否有构建一个ADO.Net连接字符串(也就是可再发行),一个标准的对话框? [英] Is there a standard dialog for constructing an ADO.Net connection string (that is redistributable)?

查看:178
本文介绍了是否有构建一个ADO.Net连接字符串(也就是可再发行),一个标准的对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个标准的对话框,征求了ADO.net连接字符串的用户输入。这是容易做到的OLEDB连接字符串如下所述: 上MSDASC.DataLinks()MSDN文章。提示

I want to use a standard dialog to solicit user input of an ADO.net connection string. It is trivial to do for the oledb connection string as described here: MSDN Article on MSDASC.DataLinks().Prompt

我还发现,使用Microsoft.Data.ConnectionUI.dll和MicrosoftData.ConnectionUI.Dialog.dll从VS(实例的 HOWTO:从你自己的code 使用Visual Studio 2005的选择数据源对话框)。

I've also found examples that use Microsoft.Data.ConnectionUI.dll and MicrosoftData.ConnectionUI.Dialog.dll from VS (HOWTO: Using the Choose Data Source dialog of Visual Studio 2005 from your own code).

不幸的是这些DLL文件未获得许可的重新分配。

Unfortunately these DLLs are not licensed for redistribution.

有没有一个标准的对话框,选择能与我的应用程序分发的数据源?

Is there a standard dialog for choosing a data source that can be distributed with my application?

推荐答案

该人士$ ​​C $下这些DLL现已:<一href="http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-$c$c-is-released-on-$c$c-gallery.aspx" rel="nofollow">http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-$c$c-is-released-on-$c$c-gallery.aspx

The source code for these DLLs is now available: http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-code-is-released-on-code-gallery.aspx

您也可以以编程方式使用数据链接属性做到这一点:

Also you can do this programmatically using the DataLink Properties:

从COM选项卡添加引用ADODB.DLL(从.NET参考)和Microsoft OLE DB服务组件1.0类型库在Visual Studio中引用标签。

using ADODB;
using Microsoft.Win32;
public partial class ConnectionStringStep : Form
    {
        private const string MSSQL_PROVIDER = "Provider=SQLOLEDB.1";

        private const string ORACLE_PROVIDER = "Provider=MSDAORA.1";

        private const string MSSQL = "MSSQL";

        public ConnectionStringStep()
        {
            InitializeComponent();
        }


        private static string DataBaseType()
        {
            //get the data from some previous screen or some kind of storage
            return MyStorage.GetProperty("DATABASE_TYPE") ?? "MSSQL";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var dataBaseType = DataBaseType();

            var adodbConnection = new Connection
                                      {
                                          ConnectionString = dataBaseType == MSSQL ? MSSQL_PROVIDER : ORACLE_PROVIDER
                                      };

            object connection = (object) adodbConnection;

            var dialog = new MSDASC.DataLinks();

            dialog.PromptEdit(ref connection);

            connectionTextBox.Text = adodbConnection.ConnectionString;
        }
    }

<一个href="http://taswar.zeytinsoft.com/2011/07/20/building-an-installer-and-displaying-data-link-properties-dialog-box-for-connection-string/"相对=nofollow>数据链接属性参考

这篇关于是否有构建一个ADO.Net连接字符串(也就是可再发行),一个标准的对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆