Как правильно использовать MessageBox? - C#
Формулировка задачи:
как мне правильно использовать if catch для того чтоб при отсутствии файла при подключении мне выводилось сообщение
private void comboBox1_MouseDown(object sender, MouseEventArgs e)
{
using (var connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\bas1.mdb"))
{
connection.Open();
using (OleDbCommand command = connection.CreateCommand())
{
command.CommandText = "Select id, name from Otdel;";
var table = new DataTable();
table.Load(command.ExecuteReader());
comboBox1.DataSource = table;
comboBox1.ValueMember = "id";
comboBox1.DisplayMember = "name";
//command.ExecuteNonQuery();
}
connection.Close();
}
}Решение задачи: «Как правильно использовать MessageBox?»
textual
Листинг программы
try
{
//Ваш код
}
catch(Exception ex1)
{
MessageBox.Show(ex1.Message);
}