本文介绍了在下面的表格中执行..但是值不保存在数据库中。 PLZ解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for (int i = 0; i < gvLeaveBank.Rows.Count; i++)
            {

                double dblTaken = 0, dblBalance = 0, dblLastYear = 0, dblCurrentyear = 0, dblNoOfDays = 0;
                Label lblLastyear2013 = (Label)gvLeaveBank.Rows[i].FindControl("lblLastyear2013");
                Label lblCurrentyear2014 = (Label)gvLeaveBank.Rows[i].FindControl("lblCurrentyear2014");
             //Label lblNoOfDays = (Label)gvLeaveBank.Rows[i].FindControl("lblNoOfDays");
                Label lblTakenDays = (Label)gvLeaveBank.Rows[i].FindControl("lblTakenDays");
                Label lblRemainingDays = (Label)gvLeaveBank.Rows[i].FindControl("lblRemainingDays");
                Label lblLeaveType = (Label)gvLeaveBank.Rows[i].FindControl("lblLeaveType");

               dblBalance = (dblLastYear + dblCurrentyear) - dblTaken;
                string LvTypeId = "";
                BBEL.lv_type_name = lblLeaveType.Text;
                //BBEL.comp_id = Convert.ToInt16(Session["compid"]);
                //BBEL.lv_type_id = Convert.ToInt16(Session["LvTypeId"]);

                     DataSet dt = new DataSet();
            DBUtilities db = new DBUtilities();
            SqlParameter[] parameters = new SqlParameter[]
		        {
                     new SqlParameter("@lv_type_name", BBEL.lv_type_name),
                     // new SqlParameter("@lv_type_id", BBEL.lv_type_id),
                      //new SqlParameter("@comp_id", BBEL.comp_id)
                };
            dt = db.ExecuteParamerizedSelectCommandDataset("sp_getLeaveID1", CommandType.StoredProcedure, parameters);
            try
            {
                LvTypeId = dt.Tables[0].Rows[0][0].ToString();

            }
            catch
            { }
                BBEL.lq_leave_prev_days = Convert.ToDecimal(lblLastyear2013.Text);
                BBEL.lq_leave_days = Convert.ToDecimal(lblCurrentyear2014.Text);
             // BBEL.lq_leave_days = Convert.ToDecimal(lblNoOfDays.Text);
                BBEL.lq_leave_taken = Convert.ToDecimal(lblTakenDays.Text);
                BBEL.lq_leave_balance = Convert.ToDecimal(lblRemainingDays.Text);
                BBEL.comp_id = Convert.ToInt16(Session["compid"]);
                BBEL.emp_code = txtEmpCode.Text;
             // BBEL.lv_type_id = Convert.ToInt16(Session["LvTypeId"]);
             // BBEL.lv_type_name = txtEmpName.Text;
                BBEL.lv_type_id = Convert.ToInt16(LvTypeId);
                BBEL.lq_year = Convert.ToInt16(ddlYear.SelectedItem.Text);
             // BBLL.UpdateEmpLeaveQuota(BBEL);
                if (BBLL.UpdateEmpLeaveQuota1(BBEL) == true)
                {

                //   // ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "LeaveRequest", "alert('LeaveRequest details Updated successfully');", true);

                }
            }
            btnGetList_Click(sender, e);

        }



[edit]已添加代码块 - OriginalGriff [/ edit]


[edit]Code block added - OriginalGriff[/edit]

推荐答案

SqlParameter[] parameters = new SqlParameter[]
    {
         new SqlParameter("@lv_type_name", BBEL.lv_type_name),
         // new SqlParameter("@lv_type_id", BBEL.lv_type_id),
          //new SqlParameter("@comp_id", BBEL.comp_id)
    };

所以它会编译:

So it will compile:

SqlParameter[] parameters = new SqlParameter[]
    {
         new SqlParameter("@lv_type_name", BBEL.lv_type_name)
         // new SqlParameter("@lv_type_id", BBEL.lv_type_id),
          //new SqlParameter("@comp_id", BBEL.comp_id)
    };

但是我猜你从SQL那里得到一个错误,因为SP可能期望的两个参数被注释掉了,所以也没有捕获...

But I'd guess that you get an error from SQL you aren;t catching as well, given that two of the parameters the SP is probably expecting are commented out...


这篇关于在下面的表格中执行..但是值不保存在数据库中。 PLZ解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 18:36