hey.........i m new in asp.net ....and following is the class library.... ........can somebody tell me the working of the following code like why catch{} is used why finally is used and all this
public abstract class clscon
{
protected SqlConnection con = new SqlConnection();
public clscon()
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
}
}
public class clsproduct : clscon
{
public void ins_product(clsproductprp objprp)
{
SqlCommand inscmd = new SqlCommand();
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
inscmd.CommandText = "spInsProduct";
inscmd.CommandType = CommandType.StoredProcedure;
inscmd.Connection = con;
inscmd.Parameters.AddWithValue("@fancategoryid", objprp.categoryidprp);
inscmd.Parameters.AddWithValue("@fsProductname", objprp.productnameprp);
inscmd.Parameters.AddWithValue("@fanunitPrice", objprp.unitPriceprp);
inscmd.Parameters.AddWithValue("@fanunitinstock", objprp.unitinStockprp);
inscmd.Parameters.AddWithValue("@fanQuantityperunit", objprp.Quantityperunitprp);
inscmd.ExecuteNonQuery();
}
catch
{
}
finally
{
inscmd.Dispose();
}
}