界面配置连接字符串

来源:互联网 发布:众泰e200和知豆2 知乎 编辑:程序博客网 时间:2024/04/29 03:10

一、添加引用
C:/Program Files/Microsoft Visual Studio 8/Common7/IDE/Microsoft.Data.ConnectionUI.Dialog.dll

二、引入名称空间

C# code
using Microsoft.Data.ConnectionUI;



三、代码

C# code
DataConnectionDialog dlg = new DataConnectionDialog(); dlg.DataSources.Add(DataSource.SqlDataSource); dlg.SelectedDataProvider = DataProvider.SqlDataProvider; DataConnectionDialog.Show(dlg, this);


比如说放在一个按钮的Click事件里

C# code
private void button1_Click(object sender, EventArgs e){ DataConnectionDialog dlg = new DataConnectionDialog(); dlg.DataSources.Add(DataSource.SqlDataSource); dlg.SelectedDataProvider = DataProvider.SqlDataProvider; DataConnectionDialog.Show(dlg, this); }



四、运行

原创粉丝点击