based on this following code i am going to get data from indent table by using stored procedure with two arguments (indno, incharge). so whenever the system exceptions ( like sql exception, Exception etc,.) occurred then i want to handle with custom exceptions like DAO catch block.. but not working.. i dont know where i did mistake.
Thanks in advance..
What I have tried:
public DataSet GetIndentsDetails(int indno,string Incharge)
{
DataSet DsIndentDetails = new DataSet();
try
{
if (dbConn == null)
dbConn = CommonProcedures.GetConnection();
dbCmd = dbConn.GetStoredProcCommand("usp_GetAllIndents");
dbConn.AddInParameter(dbCmd, "IndentNo", DbType.Int32, indno);
dbConn.AddInParameter(dbCmd, "Incharge", DbType.String, Incharge);
DsIndentDetails = (DataSet)dbConn.ExecuteDataSet(dbCmd);
return DsIndentDetails;
}
catch (DBConnOpeningException dbConnOpenEx)
{
throw new DBConnOpeningException("Unable to Connect Database");
}
catch(DBSelectFailedException dbSelExc)
{
throw new DBSelectFailedException("Select Statement Failed");
}
catch (DAOException DAOEx)
{
throw new DAOException("DAOException Occured");
}
catch (IndentsListException ilistEx)
{
throw new IndentsListException("Could not load Indent List");
}
catch(ERPException erpEx)
{
throw new ERPException("ERPException Occured");
}
finally
{
dbConn = null;
}
}
Custom Exception
--------------------
public class ERPException : System.Exception
{
public ERPException():base()
{
}
public ERPException(string arg1,System.Exception arg2):base( String.Format( "{0}",arg1), arg2 )
{
}
public ERPException(string arg1): base (String.Format("{0}",arg1))
{
}
}
public class DAOException : ERPException
{
public DAOException(): base()
{
}
public DAOException(string arg1,System.Exception arg2):base(String.Format("{0}",arg1), arg2)
{
}
public DAOException(string arg1):base(String.Format("{0}",arg1))
{
}
}