I am using Try Catch for all my Database related operation. During this activity I use Try Catch even for statements where I am sending parameters to ADO.Net Procedure and not actually calling that Procedure. Will it effect performance of application if I am using Try Catch to monitor codes where actually Exception can never occurs.
Ex. 1)
Try
{
SqlParameter[] spParameters =
{ new SqlParameter("@Batch_ID", SqlDbType.BigInt),
new SqlParameter("@Terminal_ID", SqlDbType.VarChar,8),
new SqlParameter("@MID",SqlDbType.VarChar,15)
spParameters[0].Value = nBatch_ID;
spParameters[1].Value = strTerminal_ID;
spParameters[2].Value = strMID;
objResponse.ResponseValue = MyBlock.ExecuteDataset(strConString,
"Insert_Act_Txn", spParameters);
}
catch(Exception Ex)
{
//logger function to write exception in log file
}
Ex. 2)
SqlParameter[] spParameters =
{ new SqlParameter("@Batch_ID", SqlDbType.BigInt),
new SqlParameter("@Terminal_ID", SqlDbType.VarChar,8),
new SqlParameter("@MID",SqlDbType.VarChar,15)
spParameters[0].Value = nBatch_ID;
spParameters[1].Value = strTerminal_ID;
spParameters[2].Value = strMID;
Try
{
objResponse.ResponseValue = MyBlock.ExecuteDataset
(strConString, "Insert_Act_Txn", spParameters);
}
catch(Exception Ex)
{
//logger function to write exception in log file
}
In example-I am using try catch statement where I am creating parameter for procedure and assigning value to it where run-time exception can never occur and than calling actual procedure but in Ex.-2 I am using it only when I am actually calling this procedure.
Which way is good if I think from performance point of view