public static void ShowSQLConnectionDialog() { //var dlg = new DataConnectionDialog(); //DataSource.AddStandardDataSources(dlg); //dlg.SelectedDataSource = DataSource.SqlDataSource; //if (DataConnectionDialog.Show(dlg) == System.Windows.Forms.DialogResult.OK) // MessageBox.Show(dlg.ConnectionString, Utilities.AppTitle); if (dataconnfc == null) { return; } var dlg = dataconnfc.CreateConnectionDialog(); dlg.AddAllSources(); dlg.SelectedSource = new Guid("{067ea0d9-ba62-43f7-9106-34930c60c528}"); dlg.SelectedProvider = new Guid("{91510608-8809-4020-8897-fba057e22d54}"); dlg.SafeConnectionString = (string)dte.Properties["TFS Productivity Tools", "General"].Item("TFSConnString").Value; if (dlg.ShowDialog()) { dte.Properties["TFS Productivity Tools", "General"].Item("TFSConnString").Value = dlg.SafeConnectionString; } dlg.Dispose(); }
internal void ShowDialog() { var dialog = _dialogFactory.CreateConnectionDialog(); if (dialog == null) { throw new InvalidOperationException(Resources.EntityDataConnectionDialog_NoDataConnectionDialog); } RaiseBeforeAddSourcesEvent(); dialog.AddSources(IsSupportedProvider); RaiseAfterAddSourcesEvent(); dialog.LoadSourceSelection(); RaiseBeforeShowDialogEvent(); var dc = dialog.ShowDialog(true); RaiseAfterShowDialogEvent(); if (dialog.SaveSelection && dc != null) { dialog.SaveProviderSelections(); dialog.SaveSourceSelection(); } if (dc != null) { try { SelectedExplorerConnection = _dataExplorerConnectionManager.AddConnection( null, dc.Provider, dc.EncryptedConnectionString, true); SelectedConnection = dc; } catch (XmlException xmlException) { // AddConnection() call above can throw an XmlException if the connection cannot be made throw new InvalidOperationException( String.Format( CultureInfo.CurrentCulture, Resources.EntityDataConnectionDialog_DataConnectionInvalid, xmlException.Message), xmlException); } } }