here default is my class name and here I had declared my tran
public partial class Default : System.Web.UI.Page
{
businesslogiclayer bl = new businesslogiclayer();
SqlDataReader dr;
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["skoolConnectionString"].ConnectionString);
SqlTransaction tran;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
---------------------------------------------------------------------------------
if (numbofinstlments > 0)
{
if (cn.State == ConnectionState.Closed)
cn.Open();
tran = cn.BeginTransaction();
try
{
bl.SpecialStudentDetails(admisionnumber, stdname, surname, dateofbirth, dateofjoin, clas, section, schoolname, prevdatejoin, prevyearsstudied, skooladdress, reasonfordiscont, fathername, mothername, fatheroccupation, motheroccupation, address, paymnttype, modeofpaymnt, donation, annualsalary,discount,feamountpaid, emailid, contactnumber, istcsubmitted, dateofbirthproof, lastclasspercentage, permntaddress, image, phonenumber);
for (int i = 1; i <= numbofinstlments; i++)
{
string gvndat=tb[tempcount].Text;
tempcount++;
double amnt = Convert.ToDouble(tb[tempcount].Text);
tempcount += 2;
bl.SpecialStudentPaymentDetails(admisionnumber, gvndat, amnt, clas, section,i);
cnt++;
}
tran.Commit();
}
catch (Exception ex)
{
Response.Write( ex.Message);
tran.Rollback();
}
}
else
{
r = bl.InsertStudentDetails(admisionnumber, stdname, surname, dateofbirth, dateofjoin, clas, section, schoolname, prevdatejoin, prevyearsstudied, skooladdress, reasonfordiscont, fathername, mothername, fatheroccupation, motheroccupation, address, paymnttype, modeofpaymnt, donation, annualsalary, discount, feamountpaid, emailid, contactnumber, istcsubmitted, dateofbirthproof, lastclasspercentage, permntaddress, image, phonenumber);
}
if (r > 0 || numbofinstlments==cnt)
{
Label1.Visible = true;
Label1.Text = stdname + " With AdmissionNumber " + admisionnumber + " Is Successfully Inserted ";
}
Vinay_moduga, if this helps please login to Mark As Answer. | Alert Moderator