I have the following code make the connection and query the bd sql server:
public DataTable ejecutarComandoConsultar(SqlCommand varComand)
{
SqlDataAdapter adapatador = new SqlDataAdapter();
DataTable tabla = new DataTable();
try
{
conexionServidor.Open();
adapatador.SelectCommand = comando;
adapatador.Fill(tabla);
return tabla;
}
catch
{
throw;
}
finally { conexionServidor.Close(); }
}
What I want to do is that when there is an error in the connection, do not show the error to the user, but show him a view. I have tried adding the following in the web.config:
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="~/Reportes/error" />
</customErrors>
</system.web>
but it does not work for me. thanks in advance.