Click here to Skip to main content
15,922,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i run this code it gives correct details for 1 asset number value.
but if i add multiple asset number it gives me pre-defined error.
C#
private void UpdateAssetNumber(string requestId)
   {

       clsDatabase objDb = new clsDatabase();
       clsUtility objUtil = new clsUtility();
       SendEmail objMail = new SendEmail();
       SqlTransaction objTrans;

       string TableName = "Assets_Requisition_Detail_Controller";

       string FieldsName = string.Empty;
       string FieldsValue = string.Empty;
       string todayDate = objUtil.fncGetDate();
       bool flg = false;

       try
       {
           objDb.fncOpenConnection();
           objTrans = objDb.cnnConnection.BeginTransaction();

           FieldsName = "Asset_No$";
           foreach (GridViewRow row in grdEntry.Rows)
           {
               Label lblDetailId = row.FindControl("lblDetailId") as Label;
               TextBox txtAssetNo = row.FindControl("txtAssetNo") as TextBox;

               FieldsValue = "'" + txtAssetNo.Text + "'$'";
               flg = objDb.fncModifyRecord(TableName, FieldsName, FieldsValue, "Request_Id= " + requestId + " AND IsActive = 'TRUE' AND Detail_Id = " + lblDetailId.Text, ref objDb.cnnConnection, ref objTrans);
               if (!flg)
               {
                   break;
               }
           }

           if (flg)
           {
               flg = UpdateRquestStatus(lblPk.Text, ref objDb.cnnConnection, ref objTrans);
           }

           if (flg)
           {
               objTrans.Commit();
               SearchRequest();
               pnlNew.Visible = false;
               pnlSearch.Visible = true;
               lblMsg.Text = objUtil.fncGetErrorDesc(1);
               objMail.SendCodeOpenedEmail("ASSET", Convert.ToInt32(lblPk.Text));

           }
           else
           {
               objTrans.Rollback();
               lblMsg.Text = objUtil.fncGetErrorDesc(-1);
           }
           pnlMsg.Visible = true;

       }
       catch (Exception ex)
       {
           throw ex;
       }
       finally
       {
           objDb.fncCloseConnection(objDb.cnnConnection);
           objTrans = null;
       }
   }
Posted
Comments
BillWoodruff 29-Dec-15 2:28am    
"add multiple asset number"

Please clarify what the code looks like when you are doing this, and what specific error message you get. It's hard to guess what could go wrong if we can't see what the code is like where the error happens.
Sinisa Hajnal 29-Dec-15 3:09am    
Try to remove multiple if (flg) and change throw ex; to throw; this way you will re-throw existing exception and keep original error stack trace.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900