'先引用Microsoft.Data.ConnectionUI.Dialog.dll(在VS2005安装路径的IDE目录下)
'将以下代码加入相应事件过程
Dim dialog As DataConnectionDialog = New DataConnectionDialog()
dialog.DataSources.Add(DataSource.SqlDataSource)
dialog.DataSources.Add(DataSource.OdbcDataSource)
dialog.DataSources.Add(DataSource.OracleDataSource)
dialog.DataSources.Add(DataSource.AccessDataSource)
dialog.SelectedDataSource = DataSource.SqlDataSource
dialog.SelectedDataProvider = DataProvider.SqlDataProvider
DataConnectionDialog.Show(dialog)
If dialog.DialogResult = Windows.Forms.DialogResult.OK Then
Me.TextBox1.Text = dialog.ConnectionString
ElseIf dialog.DialogResult = Windows.Forms.DialogResult.Cancel Then
Me.Close()
End If
DataConnectionDialog dialog = new DataConnectionDialog();
dialog.DataSources.Add(DataSource.SqlDataSource);
dialog.DataSources.Add(DataSource.OdbcDataSource);
dialog.DataSources.Add(DataSource.OracleDataSource);
dialog.DataSources.Add(DataSource.AccessDataSource);
dialog.SelectedDataSource = DataSource.SqlDataSource;
dialog.SelectedDataProvider = DataProvider.SqlDataProvider;
DataConnectionDialog.Show(dialog);
if (dialog.DialogResult == DialogResult.OK)
{ textBox1.Text = dialog.ConnectionString; }
else if (dialog.DialogResult == DialogResult.Cancel)
{ }
//Me.Close();