Create a common Database Connection dialog box using the Visual Studio Dynamic Connection Library

Source: Internet
Author: User
1. In the VS (here Directory file takes vs2010 as an example) under the installation directory ("%visual Studio installation directory%/common10/ide/microsoft.data.connectionui.dialog.dll" ) Find Microsoft.Data.ConnectionUI.dll, Microsoft.Data.ConnectionUI.Dialog.dll and Chinese resources file Microsoft.Data.ConnectionUI.Dialog.resources.dll, note that the Chinese resources files need to be placed under the Zh-chs folder;



2. Add references to the above two DLL files in the project file;

3, the specific code is as follows:

private void Button1_Click (object sender, EventArgs e)        {            dataconnectiondialog dialog = new Dataconnectiondialog ();            Dialog. Datasources.add (Datasource.accessdatasource);            Dialog. Datasources.add (Datasource.odbcdatasource);            Dialog. Datasources.add (Datasource.oracledatasource);            Dialog. Datasources.add (Datasource.sqldatasource);            Dialog. Datasources.add (Datasource.sqlfiledatasource);            Dialog. Selecteddatasource = Datasource.sqldatasource;            Dialog. Selecteddataprovider = Dataprovider.sqldataprovider;            if (dataconnectiondialog.show (dialog, this) = = DialogResult.OK)            {                //conndlg.connectionstring;            }        }

Operating effect:



Show when re-open, before selecting the connection string:

Dataconnectiondialog dialog = new Dataconnectiondialog ();                    Dialog. Datasources.add (Datasource.accessdatasource);            Dialog. Datasources.add (Datasource.odbcdatasource);            Dialog. Datasources.add (Datasource.oracledatasource);            Dialog. Datasources.add (Datasource.sqldatasource);            Dialog. Datasources.add (Datasource.sqlfiledatasource);            Dialog. Selecteddatasource = Datasource.sqldatasource;            Dialog. Selecteddataprovider = Dataprovider.sqldataprovider;            The connection string dialog previously saved by the Dataconnectiondialog control            . ConnectionString = str;            ConnectionString has a value, it will be displayed            dataconnectiondialog.show (dialog, this);


The above is the content of creating a Common Database Connection dialog box using the Visual Studio Dynamic Connection library, and more about topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.