Exemplo n.º 1
0
        private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
        {
            OleDBBuilderContext context = DataContext as OleDBBuilderContext;

            if (context != null)
            {
                context.Password = ((PasswordBox)sender).Password;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// For Save and Apply buttons- test the connection and return true.
        /// Make sure that ButtonSave_Click sets the context property Save = true.
        /// </summary>
        private void ReturnTrueDialogResult()
        {
            OleDBBuilderContext context = DataContext as OleDBBuilderContext;

            using (OleDbConnection connection = new OleDbConnection(context.OleDBString))
            {
                try
                {
                    connection.Open();
                }
                catch (Exception ex)
                {
                    MessageBoxResult result = MessageBox.Show($"Testing the connection string '{context.OleDBString}' created the following error: {ex.Message}{Environment.NewLine}{Environment.NewLine}Continue using this connection string?", "Warning", MessageBoxButton.OKCancel);
                    if (result != MessageBoxResult.OK)
                    {
                        return;
                    }
                }
            }
            DialogResult = true;
        }