C# Programming
03-28-2010, 07:40 PM
hi
a function called Save() saves user input to database
should i write try catch block like this
private void Save()
{
try {
//My code goes here
}
catch (SqlException sqlEx)
{
MessageBox.Show(sqlEx.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
or should i write it like this in the function or event handler that calls Save();
try {
Save();
}
catch (SqlException sqlEx)
{
MessageBox.Show(sqlEx.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
and what is the difference, if there was a difference
and which is a better coding practice
thanks
a function called Save() saves user input to database
should i write try catch block like this
private void Save()
{
try {
//My code goes here
}
catch (SqlException sqlEx)
{
MessageBox.Show(sqlEx.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
or should i write it like this in the function or event handler that calls Save();
try {
Save();
}
catch (SqlException sqlEx)
{
MessageBox.Show(sqlEx.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
and what is the difference, if there was a difference
and which is a better coding practice
thanks