Can two catch blocks be executed?

Answer Posted / khushnood alam

two catch block can be executed but need coresponding try
block
ex
DbTransaction Transaction = Connection.BeginTransaction();
try
{
RemoteDB.ExecuteNonQuery(cmdBfcNew,
Transaction);
if (Convert.ToInt64
(AddBfcNewOutgoingDetails["ID"]) == -1)
{
mID = Convert.ToInt64
(RemoteDB.GetParameterValue(cmdBfcNew, "@ReturnID"));
}
else
{
mID = Convert.ToInt64
(AddBfcNewOutgoingDetails["ID"]);
}
try
{
DbCommand cmdOutgoing =
LocalDB.GetStoredProcCommand
("usp_Outgoing2UpdateAfterUploadingData");
LocalDB.AddInParameter
(cmdOutgoing, "@AwbNo", DbType.String,
AddBfcNewOutgoingDetails["AwbNo"]);
}
catch (Exception Ex)
{
Transaction.Rollback();
Transaction1.Rollback();
return Ex.Message;
}
catch (Exception Ex)
{
Transaction.Rollback
();
return Ex.Message;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is reflection in c#?

496


Is string a data type in c#?

489


What is Delegate and what is it used for ?

575


What is a generic method?

489


Explain About CLS?

545






What is difference between singleton and static class in c#?

478


What is the main usage of keyword “virtual” ? How does it work for a method or property?

515


Are there constructors in c sharp?

571


What is difference between il and dll ?

531


Describe the parts of assembly.

524


Tell me the difference between call by value and call by reference.

538


What is the system namespace?

476


What is datarelation c#?

463


What is the difference between int16 and int32 in c#?

476


Why do we use struct in c#?

483