private void AddButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var info = EnvDteHelper.PromptForInfo(_package);
                if (info.DatabaseType == DatabaseType.SQLCE35)
                {
                    return;
                }

                var databaseList = EnvDteHelper.GetDataConnections(_package);
                comboBox1.DisplayMemberPath = "Value.Caption";
                comboBox1.ItemsSource       = databaseList;

                int i = 0;
                foreach (var item in databaseList)
                {
                    if (item.Key == info.ConnectionString)
                    {
                        comboBox1.SelectedIndex = i;
                    }
                    i++;
                }
            }

            catch (Exception exception)
            {
                EnvDteHelper.ShowMessage(exception.ToString());
            }
        }
Пример #2
0
        DatabaseConnectionModel IVisualStudioAccess.PromptForNewDatabaseConnection()
        {
            var info = EnvDteHelper.PromptForInfo(_package);

            if (info.DatabaseType == DatabaseType.Undefined)
            {
                return(null);
            }

            return(new DatabaseConnectionModel
            {
                ConnectionName = info.Caption,
                ConnectionString = info.ConnectionString,
                DatabaseType = info.DatabaseType
            });
        }