in the below mention code how can we convert by looping.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: in the below mention code how can we convert by looping.

  1. #1
    Join Date
    Mar 2010
    Posts
    4

    Lightbulb in the below mention code how can we convert by looping.

    Statement stmt3=con.createStatement();
    ResultSet rs3=stmt3.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='3' AND PBR_YEAR='"+yr2+"') ");
    if(rs3.next())
    {

    cgegis3=rs3.getString("PBR_CGEGIS");
    itax3=rs3.getString("PBR_ITAX");
    gpf_sub3=rs3.getString("PBR_GPF_SUB");
    hba_adv3=rs3.getString("PBR_HBA_ADV");
    hba_int3=rs3.getString("PBR_HBA_INT");
    cpf_sub3=rs3.getString("PBR_CPF_SUB");
    pli3=rs3.getString("PBR_PLI");
    lic3=rs3.getString("PBR_LIC");
    it_scharge3=rs3.getString("PBR_IT_SCHARGE");
    afee3=rs3.getString("PBR_AFEE");
    edu_cess3=rs3.getString("PBR_EDU_CESS");
    pm_relf3=rs3.getString("PBR_PM_RELF");
    govt_cont3=rs3.getString("PBR_GOVT_CONT");
    emp_tier_13=rs3.getString("PBR_EMP_TIER_1");

    }
    else
    {
    cgegis3="0";
    itax3="0";
    gpf_sub3="0";
    hba_adv3="0";
    hba_int3="0";
    cpf_sub3="0";
    pli3="0";
    lic3="0";
    it_scharge3="0";
    afee3="0";
    edu_cess3="0";
    pm_relf3="0";
    govt_cont3="0";
    emp_tier_13="0";
    }
    stmt3.close();

    Statement stmt4=con.createStatement();
    ResultSet rs4=stmt4.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='4' AND PBR_YEAR='"+yr2+"') ");
    if(rs4.next())
    {

    cgegis4=rs4.getString("PBR_CGEGIS");
    itax4=rs4.getString("PBR_ITAX");
    gpf_sub4=rs4.getString("PBR_GPF_SUB");
    hba_adv4=rs4.getString("PBR_HBA_ADV");
    hba_int4=rs4.getString("PBR_HBA_INT");
    cpf_sub4=rs4.getString("PBR_CPF_SUB");
    pli4=rs4.getString("PBR_PLI");
    lic4=rs4.getString("PBR_LIC");
    it_scharge4=rs4.getString("PBR_IT_SCHARGE");
    afee4=rs4.getString("PBR_AFEE");
    edu_cess4=rs4.getString("PBR_EDU_CESS");
    pm_relf4=rs4.getString("PBR_PM_RELF");
    govt_cont4=rs4.getString("PBR_GOVT_CONT");
    emp_tier_14=rs4.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis4="0";
    itax4="0";
    gpf_sub4="0";
    hba_adv4="0";
    hba_int4="0";
    cpf_sub4="0";
    pli4="0";
    lic4="0";
    it_scharge4="0";
    afee4="0";
    edu_cess4="0";
    pm_relf4="0";
    govt_cont4="0";
    emp_tier_14="0";
    }
    stmt4.close();

    Statement stmt5=con.createStatement();
    ResultSet rs5=stmt5.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='5' AND PBR_YEAR='"+yr2+"') ");
    if(rs5.next())
    {

    cgegis5=rs5.getString("PBR_CGEGIS");
    itax5=rs5.getString("PBR_ITAX");
    gpf_sub5=rs5.getString("PBR_GPF_SUB");
    hba_adv5=rs5.getString("PBR_HBA_ADV");
    hba_int5=rs5.getString("PBR_HBA_INT");
    cpf_sub5=rs5.getString("PBR_CPF_SUB");
    pli5=rs5.getString("PBR_PLI");
    lic5=rs5.getString("PBR_LIC");
    it_scharge5=rs5.getString("PBR_IT_SCHARGE");
    afee5=rs5.getString("PBR_AFEE");
    edu_cess5=rs5.getString("PBR_EDU_CESS");
    pm_relf5=rs5.getString("PBR_PM_RELF");
    govt_cont5=rs5.getString("PBR_GOVT_CONT");
    emp_tier_15=rs5.getString("PBR_EMP_TIER_1");
    }

    else
    {
    cgegis5="0";
    itax5="0";
    gpf_sub5="0";
    hba_adv5="0";
    hba_int5="0";
    cpf_sub5="0";
    pli5="0";
    lic5="0";
    it_scharge5="0";
    afee5="0";
    edu_cess5="0";
    pm_relf5="0";
    govt_cont5="0";
    emp_tier_15="0";
    }
    stmt5.close();

    Statement stmt6=con.createStatement();
    ResultSet rs6=stmt6.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='6' AND PBR_YEAR='"+yr2+"') ");
    if(rs6.next())
    {
    cgegis6=rs6.getString("PBR_CGEGIS");
    itax6=rs6.getString("PBR_ITAX");
    gpf_sub6=rs6.getString("PBR_GPF_SUB");
    hba_adv6=rs6.getString("PBR_HBA_ADV");
    hba_int6=rs6.getString("PBR_HBA_INT");
    cpf_sub6=rs6.getString("PBR_CPF_SUB");
    pli6=rs6.getString("PBR_PLI");
    lic6=rs6.getString("PBR_LIC");
    it_scharge6=rs6.getString("PBR_IT_SCHARGE");
    afee6=rs6.getString("PBR_AFEE");
    edu_cess6=rs6.getString("PBR_EDU_CESS");
    pm_relf6=rs6.getString("PBR_PM_RELF");
    govt_cont6=rs6.getString("PBR_GOVT_CONT");
    emp_tier_16=rs6.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis6="0";
    itax6="0";
    gpf_sub6="0";
    hba_adv6="0";
    hba_int6="0";
    cpf_sub6="0";
    pli6="0";
    lic6="0";
    it_scharge6="0";
    afee6="0";
    edu_cess6="0";
    pm_relf6="0";
    govt_cont6="0";
    emp_tier_16="0";
    }
    stmt6.close();

    Statement stmt7=con.createStatement();
    ResultSet rs7=stmt7.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='7' AND PBR_YEAR='"+yr2+"') ");
    if(rs7.next())
    {
    cgegis7=rs7.getString("PBR_CGEGIS");
    itax7=rs7.getString("PBR_ITAX");
    gpf_sub7=rs7.getString("PBR_GPF_SUB");
    hba_adv7=rs7.getString("PBR_HBA_ADV");
    hba_int7=rs7.getString("PBR_HBA_INT");
    cpf_sub7=rs7.getString("PBR_CPF_SUB");
    pli7=rs7.getString("PBR_PLI");
    lic7=rs7.getString("PBR_LIC");
    it_scharge7=rs7.getString("PBR_IT_SCHARGE");
    afee7=rs7.getString("PBR_AFEE");
    edu_cess7=rs7.getString("PBR_EDU_CESS");
    pm_relf7=rs7.getString("PBR_PM_RELF");
    govt_cont7=rs7.getString("PBR_GOVT_CONT");
    emp_tier_17=rs7.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis7="0";
    itax7="0";
    gpf_sub7="0";
    hba_adv7="0";
    hba_int7="0";
    cpf_sub7="0";
    pli7="0";
    lic7="0";
    it_scharge7="0";
    afee7="0";
    edu_cess7="0";
    pm_relf7="0";
    govt_cont7="0";
    emp_tier_17="0";
    }
    stmt7.close();

    Statement stmt8=con.createStatement();
    ResultSet rs8=stmt8.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='8' AND PBR_YEAR='"+yr2+"') ");

    if(rs8.next())
    {
    cgegis8=rs8.getString("PBR_CGEGIS");
    itax8=rs8.getString("PBR_ITAX");
    gpf_sub8=rs8.getString("PBR_GPF_SUB");
    hba_adv8=rs8.getString("PBR_HBA_ADV");
    hba_int8=rs8.getString("PBR_HBA_INT");
    cpf_sub8=rs8.getString("PBR_CPF_SUB");
    pli8=rs8.getString("PBR_PLI");
    lic8=rs8.getString("PBR_LIC");
    it_scharge8=rs8.getString("PBR_IT_SCHARGE");
    afee8=rs8.getString("PBR_AFEE");
    edu_cess8=rs8.getString("PBR_EDU_CESS");
    pm_relf8=rs8.getString("PBR_PM_RELF");
    govt_cont8=rs8.getString("PBR_GOVT_CONT");
    emp_tier_18=rs8.getString("PBR_EMP_TIER_1");
    }

    else
    {
    cgegis8="0";
    itax8="0";
    gpf_sub8="0";
    hba_adv8="0";
    hba_int8="0";
    cpf_sub8="0";
    pli8="0";
    lic8="0";
    it_scharge8="0";
    afee8="0";
    edu_cess8="0";
    pm_relf8="0";
    govt_cont8="0";
    emp_tier_18="0";
    }
    stmt8.close();

    Statement stmt9=con.createStatement();
    ResultSet rs9=stmt9.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='9' AND PBR_YEAR='"+yr2+"') ");
    if(rs9.next())
    {
    cgegis9=rs9.getString("PBR_CGEGIS");
    itax9=rs9.getString("PBR_ITAX");
    gpf_sub9=rs9.getString("PBR_GPF_SUB");
    hba_adv9=rs9.getString("PBR_HBA_ADV");
    hba_int9=rs9.getString("PBR_HBA_INT");
    cpf_sub9=rs9.getString("PBR_CPF_SUB");
    pli9=rs9.getString("PBR_PLI");
    lic9=rs9.getString("PBR_LIC");
    it_scharge9=rs9.getString("PBR_IT_SCHARGE");
    afee9=rs9.getString("PBR_AFEE");
    edu_cess9=rs9.getString("PBR_EDU_CESS");
    pm_relf9=rs9.getString("PBR_PM_RELF");
    govt_cont9=rs9.getString("PBR_GOVT_CONT");
    emp_tier_19=rs9.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis9="0";
    itax9="0";
    gpf_sub9="0";
    hba_adv9="0";
    hba_int9="0";
    cpf_sub9="0";
    pli9="0";
    lic9="0";
    it_scharge9="0";
    afee9="0";
    edu_cess9="0";
    pm_relf9="0";
    govt_cont9="0";
    emp_tier_19="0";
    }
    stmt9.close();

    Statement stmt10=con.createStatement();
    ResultSet rs10=stmt10.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='10' AND PBR_YEAR='"+yr2+"') ");
    if(rs10.next())
    {
    cgegis10=rs10.getString("PBR_CGEGIS");
    itax10=rs10.getString("PBR_ITAX");
    gpf_sub10=rs10.getString("PBR_GPF_SUB");
    hba_adv10=rs10.getString("PBR_HBA_ADV");
    hba_int10=rs10.getString("PBR_HBA_INT");
    cpf_sub10=rs10.getString("PBR_CPF_SUB");
    pli10=rs10.getString("PBR_PLI");
    lic10=rs10.getString("PBR_LIC");
    it_scharge10=rs10.getString("PBR_IT_SCHARGE");
    afee10=rs10.getString("PBR_AFEE");
    edu_cess10=rs10.getString("PBR_EDU_CESS");
    pm_relf10=rs10.getString("PBR_PM_RELF");
    govt_cont10=rs10.getString("PBR_GOVT_CONT");
    emp_tier_110=rs10.getString("PBR_EMP_TIER_1");
    }

    else
    {
    cgegis10="0";
    itax10="0";
    gpf_sub10="0";
    hba_adv10="0";
    hba_int10="0";
    cpf_sub10="0";
    pli10="0";
    lic10="0";
    it_scharge10="0";
    afee10="0";
    edu_cess10="0";
    pm_relf10="0";
    govt_cont10="0";
    emp_tier_110="0";
    }
    stmt10.close();

    Statement stmt11=con.createStatement();
    ResultSet rs11=stmt11.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='11' AND PBR_YEAR='"+yr2+"') ");
    if(rs11.next())
    {
    cgegis11=rs11.getString("PBR_CGEGIS");
    itax11=rs11.getString("PBR_ITAX");
    gpf_sub11=rs11.getString("PBR_GPF_SUB");
    hba_adv11=rs11.getString("PBR_HBA_ADV");
    hba_int11=rs11.getString("PBR_HBA_INT");
    cpf_sub11=rs11.getString("PBR_CPF_SUB");
    pli11=rs11.getString("PBR_PLI");
    lic11=rs11.getString("PBR_LIC");
    it_scharge11=rs11.getString("PBR_IT_SCHARGE");
    afee11=rs11.getString("PBR_AFEE");
    edu_cess11=rs11.getString("PBR_EDU_CESS");
    pm_relf11=rs11.getString("PBR_PM_RELF");
    govt_cont11=rs11.getString("PBR_GOVT_CONT");
    emp_tier_111=rs11.getString("PBR_EMP_TIER_1");
    }

    else
    {
    cgegis11="0";
    itax11="0";
    gpf_sub11="0";
    hba_adv11="0";
    hba_int11="0";
    cpf_sub11="0";
    pli11="0";
    lic11="0";
    it_scharge11="0";
    afee11="0";
    edu_cess11="0";
    pm_relf11="0";
    govt_cont11="0";
    emp_tier_111="0";
    }
    stmt11.close();

    Statement stmt12=con.createStatement();
    ResultSet rs12=stmt12.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='12' AND PBR_YEAR='"+yr2+"') ");
    if(rs12.next())
    {
    cgegis12=rs12.getString("PBR_CGEGIS");
    itax12=rs12.getString("PBR_ITAX");
    gpf_sub12=rs12.getString("PBR_GPF_SUB");
    hba_adv12=rs12.getString("PBR_HBA_ADV");
    hba_int12=rs12.getString("PBR_HBA_INT");
    cpf_sub12=rs12.getString("PBR_CPF_SUB");
    pli12=rs12.getString("PBR_PLI");
    lic12=rs12.getString("PBR_LIC");
    it_scharge12=rs12.getString("PBR_IT_SCHARGE");
    afee12=rs12.getString("PBR_AFEE");
    edu_cess12=rs12.getString("PBR_EDU_CESS");
    pm_relf12=rs12.getString("PBR_PM_RELF");
    govt_cont12=rs12.getString("PBR_GOVT_CONT");
    emp_tier_112=rs12.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis12="0";
    itax12="0";
    gpf_sub12="0";
    hba_adv12="0";
    hba_int12="0";
    cpf_sub12="0";
    pli12="0";
    lic12="0";
    it_scharge12="0";
    afee12="0";
    edu_cess12="0";
    pm_relf12="0";
    govt_cont12="0";
    emp_tier_112="0";
    }
    stmt12.close();

    Statement stmt1=con.createStatement();
    ResultSet rs1=stmt1.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='01' AND PBR_YEAR='"+(yr2+1) +"') ");
    if(rs1.next())
    {
    cgegis1=rs1.getString("PBR_CGEGIS");
    itax1=rs1.getString("PBR_ITAX");
    gpf_sub1=rs1.getString("PBR_GPF_SUB");
    hba_adv1=rs1.getString("PBR_HBA_ADV");
    hba_int1=rs1.getString("PBR_HBA_INT");
    cpf_sub1=rs1.getString("PBR_CPF_SUB");
    pli1=rs1.getString("PBR_PLI");
    lic1=rs1.getString("PBR_LIC");
    it_scharge1=rs1.getString("PBR_IT_SCHARGE");
    afee1=rs1.getString("PBR_AFEE");
    edu_cess1=rs1.getString("PBR_EDU_CESS");
    pm_relf1=rs1.getString("PBR_PM_RELF");
    govt_cont1=rs1.getString("PBR_GOVT_CONT");
    emp_tier_11=rs1.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis1="0";
    itax1="0";
    gpf_sub1="0";
    hba_adv1="0";
    hba_int1="0";
    cpf_sub1="0";
    pli1="0";
    lic1="0";
    it_scharge1="0";
    afee1="0";
    edu_cess1="0";
    pm_relf1="0";
    govt_cont1="0";
    emp_tier_11="0";
    }
    stmt1.close();

    Statement stmt2=con.createStatement();
    ResultSet rs2=stmt2.executeQuery("select * from EW_T_PBR_"+yr1+" where (PBR_EID="+bkpuname1+" AND PBR_MONTH='02' AND PBR_YEAR='"+(yr2+1)+"') ");
    if(rs2.next())
    {

    cgegis2=rs2.getString("PBR_CGEGIS");
    itax2=rs2.getString("PBR_ITAX");
    gpf_sub2=rs2.getString("PBR_GPF_SUB");
    hba_adv2=rs2.getString("PBR_HBA_ADV");
    hba_int2=rs2.getString("PBR_HBA_INT");
    cpf_sub2=rs2.getString("PBR_CPF_SUB");
    pli2=rs2.getString("PBR_PLI");
    lic2=rs2.getString("PBR_LIC");
    it_scharge2=rs2.getString("PBR_IT_SCHARGE");
    afee2=rs2.getString("PBR_AFEE");
    edu_cess2=rs2.getString("PBR_EDU_CESS");
    pm_relf2=rs2.getString("PBR_PM_RELF");
    govt_cont2=rs2.getString("PBR_GOVT_CONT");
    emp_tier_12=rs2.getString("PBR_EMP_TIER_1");
    }
    else
    {
    cgegis2="0";
    itax2="0";
    gpf_sub2="0";
    hba_adv2="0";
    hba_int2="0";
    cpf_sub2="0";
    pli2="0";
    lic2="0";
    it_scharge2="0";
    afee2="0";
    edu_cess2="0";
    pm_relf2="0";
    govt_cont2="0";
    emp_tier_12="0";
    }
    stmt2.close();

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: in the below mention code how can we convert by looping.

    You post a huge mass of unformatted, uncommented code, with meaningless variable names, and no explanation of what it is supposed to do or how it is supposed to work, and ask a terminally vague question about looping...

    Did you really expect an answer?

    Judge a man by his questions, rather than his answers...
    Voltaire
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    557

    Re: in the below mention code how can we convert by looping.

    Is this a decompiler generated code? Anyways:
    1. Please use CODE tags when posting code;
    2. Please explain what is the actual problem;
    3. If there is any exception thrown please post it as well;

    Posts like this one will not be answered or even read here...
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center