Answered by:
Update button on VS works SQL SP, on IIS it just saves the information already there, no update.

Question
-
User9396681 posted
I have a web form that shows some header information, you can change that information (text boxes, check box, etc.) and hit the update information button to post the information to a SQL Stored Procedure..
When I run this on Visual Studio and hit the button the information gets updated.
====VISUAL STUDIO==== declare @p14 varchar(200) set @p14=NULL declare @p15 int set @p15=NULL exec DLI_BENEFITS_HEADER_UPDATE @EMP_ID=N'ADA04',@K401_TYPE=N'DECLINED',@CONTRIBUTION_RATE_401K_AMOUNT=NULL,@CONTRIBUTION_RATE_401K_PCT=NULL,@COMPANY_LIFE_EMP=1,@COMPANY_LIFE_SPOUSE=0,@COMPANY_LIFE_CHILD=1,@COMPANY_LIFE_DEPENDENTS=99,@HEALTH_DECLINE=1,@DENTAL_DECLINE=0,@VISION_DECLINE=1,@LIFE_DECLINE=0,@NOTES=N'MY RECORD NEW RECORD INFO',@SP_MESSAGE=@p14 output,@SP_ERROR_NUMBER=@p15 output select @p14, @p15 go exec sp_reset_connection go
When I run the exact same thing in IIS it basically just puts the information back into SQL as if nothing had changed.
=====IIS===== declare @p14 varchar(200) set @p14=NULL declare @p15 int set @p15=NULL exec DLI_BENEFITS_HEADER_UPDATE @EMP_ID=N'ADA04',@K401_TYPE=N'DECLINED',@CONTRIBUTION_RATE_401K_AMOUNT=NULL,@CONTRIBUTION_RATE_401K_PCT=NULL,@COMPANY_LIFE_EMP=1,@COMPANY_LIFE_SPOUSE=0,@COMPANY_LIFE_CHILD=1,@COMPANY_LIFE_DEPENDENTS=99,@HEALTH_DECLINE=1,@DENTAL_DECLINE=0,@VISION_DECLINE=1,@LIFE_DECLINE=0,@NOTES=N'MY RECORD NEW RECORD INFO',@SP_MESSAGE=@p14 output,@SP_ERROR_NUMBER=@p15 output select @p14, @p15 Had actually changed @COMPANY_LIFE_DEPENDENTS=99 to 4 and @NOTES to @NOTES=N'MY RECORD NEW RECORD INFO WITH NEW NOTES HERE'
I am not sure what I am missing here.. sorry if it is something pretty basic and I should know better, but I have searched around trying to figure it out.
The SQL connection is SQL username and password not integrated.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeeBenefits.aspx.cs" Inherits="DLI_EMPLOYEE_BENEFITS.EmployeeBenefits" MaintainScrollPositionOnPostback="true" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DLI Employee Benefit Maintenance</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <style> html, body { height: 90%; padding: 10px; } html { display: table; margin: auto; } body { display: table-cell; vertical-align: top; width: 1024px; height: 768px; margin: 0; /* Space from this element (entire page) and others*/ padding: 20; /*space from content and border*/ border: solid blue; border-width: thin; overflow: hidden; display: block; box-sizing: border-box; } .HeaderLogo { text-align: center; } .PageTitle { text-align: center; font-size: x-large; font-weight: bold; } .LoginName { text-align: right; } .NavBar { text-align: center; margin: auto; padding: 10px; } .DivCenter { text-align: center; } .auto-style1 { width: 100%; border-collapse: collapse; } .auto-style2 { width: 100%; } .auto-style3 { width: 20%; height: 25px; } </style> </head> <body> <form id="form1" runat="server"> <div id="BODY_DIV"> <div id="PageTitle" class="PageTitle"> EMPLOYEE BENEFIT MAINTENANCE<hr /> </div> <div id="EMPLOYEE_BENEFITS_HEADER"> <table class="auto-style1"> <tr> <td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">EMP ID :</td> <td style="vertical-align: middle; text-align: right; width: 15%"> <asp:TextBox ID="tbEMPLOYEE_ID" runat="server" Width="92px"></asp:TextBox> <asp:ImageButton ID="ibGET" runat="server" ImageUrl="~/Image/elcmark.png" OnClick="ibGET_Click" /> <asp:ImageButton ID="ibRESET" runat="server" ImageUrl="~/Image/reset.png" PostBackUrl="https://dlihome.deseretlabs.com/HR/EMP_BENEFITS/EmployeeBenefits.aspx" /> </td> <td style="vertical-align: middle; text-align: center; width: 40%"> <asp:Label ID="lbEMPLOYEE_NAME" runat="server" Text="DOE, JOHN" Font-Bold="True" Font-Size="X-Large" ForeColor="Red"></asp:Label> </td> <td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">HIRE DATE :</td> <td style="vertical-align: middle; text-align: center; width: 15%"> <asp:Label ID="lbHIRE_DATE" runat="server"></asp:Label> </td> </tr> <tr> <td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">ENROLL DATE :</td> <td style="vertical-align: middle; text-align: center; width: 15%"> <asp:Label ID="lbENROLL_DATE" runat="server"></asp:Label> </td> <td style="vertical-align: middle; text-align: right; width: 55%; font-weight: bold;" colspan="2">INITAL MEETING :</td> <td style="vertical-align: middle; text-align: center; width: 15%"> <asp:Label ID="lbINITIAL_MEETING" runat="server"></asp:Label> <asp:ImageButton ID="ibINITIAL_DATE" runat="server" ImageUrl="~/Image/plus16.gif" /> </td> </tr> </table> <hr /> <table class="auto-style1" cellpadding="10px"> <tr> <td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">401K :</td> <td style="vertical-align: middle; text-align: left; width: 20%" colspan="4"> <asp:DropDownList ID="ddl401_TYPE" runat="server"> <asp:ListItem></asp:ListItem> <asp:ListItem>DECLINED</asp:ListItem> <asp:ListItem>401K</asp:ListItem> <asp:ListItem>ROTH</asp:ListItem> </asp:DropDownList> ♦ <asp:TextBox ID="tb401_PCT" runat="server" Width="25px" Wrap="False" style="text-align:center"></asp:TextBox> PERCENT ♦ $ <asp:TextBox ID="tb401_AMOUNT" runat="server" Width="64px" Wrap="False"></asp:TextBox> AMOUNT</td> </tr> <tr> <td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">COMPANY LIFE :</td> <td style="vertical-align: middle; text-align: left; width: 20%" colspan="4"> <asp:CheckBox ID="cbCOMP_LIFE_EMP" runat="server" Text="EMPLOYEE" /> ♦ <asp:CheckBox ID="cbCOMP_LIFE_SPOUSE" runat="server" Text="SPOUSE" /> ♦ <asp:CheckBox ID="cbCOMP_LIFE_CHILDREN" runat="server" Text="CHILDREN" /> ♦ <asp:TextBox ID="TbCOMP_LIFE_DEPENDENTS" runat="server" Width="25px" Wrap="False" style="text-align:center"></asp:TextBox> DEPENDENTS</td> </tr> <tr> <td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">DECLINED BENEFITS :</td> <td style="vertical-align: middle; text-align: left; width: 20%" colspan="4"> <asp:CheckBox ID="cbDECLINE_HEALTH" runat="server" Text="HEALTH" /> ♦ <asp:CheckBox ID="cbDECLINE_DENTAL" runat="server" Text="DENTAL" /> ♦ <asp:CheckBox ID="cbDECLINE_VISION" runat="server" Text="VISION" /> ♦ <asp:CheckBox ID="cbDECLINE_LIFE" runat="server" Text="VOLUNTARY LIFE" /> </td> </tr> <tr> <td style="vertical-align: middle; text-align: RIGHT; width: 20%; font-weight: bold;">NOTES:</td> <td style="vertical-align: middle; text-align: LEFT; width: 80%" colspan="4"> <asp:TextBox ID="tbNOTES" runat="server" style="margin-left: 0px" TextMode="MultiLine" Width="100%" Height="50px"></asp:TextBox> </td> </tr> <tr> <td style="vertical-align: middle; text-align: CENTER; width: 100%; font-weight: bold;" colspan="2"> <asp:ImageButton ID="ibUPDATE_HEADER" runat="server" ImageUrl="~/Image/button_update-record.png" OnClick="ibUPDATE_HEADER_Click" /> <br /> <asp:Label ID="lblSPMessageSuccess" runat="server"></asp:Label><asp:Label ID="lblSPMessageError" runat="server"></asp:Label> </td> </tr> </table> <hr style="border: 1px solid red;"/> </div> <div id="ENROLLED_BENEFITS"> <asp:GridView ID="gvEnrolledBenfits" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="dsEnrolledBenefits" Width="100%" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px"> <Columns> <asp:BoundField DataField="INS_DESCRIPTION" HeaderText="DESCRIPTION" SortExpression="INS_DESCRIPTION"> <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="20%" /> <ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:BoundField> <asp:BoundField DataField="AMOUNT" DataFormatString="{0:c}" HeaderText="AMOUNT PPC" SortExpression="AMOUNT" > <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> <ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> </asp:BoundField> <asp:BoundField DataField="LIFE_AMOUNT" DataFormatString="{0:c}" HeaderText="LIFE AMOUNT" SortExpression="LIFE_AMOUNT" > <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> <ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> </asp:BoundField> <asp:BoundField DataField="DEPENDENT_CHIDREN" HeaderText="DEPENDENT CHIDREN" SortExpression="DEPENDENT_CHIDREN" > <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> <ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> </asp:BoundField> <asp:BoundField DataField="START_DATE" DataFormatString="{0:d}" HeaderText="START DATE" SortExpression="START_DATE" > <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> <ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> </asp:BoundField> <asp:BoundField DataField="END_DATE" DataFormatString="{0:d}" HeaderText="END DATE" SortExpression="END_DATE" > <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> <ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" /> </asp:BoundField> </Columns> <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" /> <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" /> <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" /> <RowStyle BackColor="White" ForeColor="#330099" /> <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" /> <SortedAscendingCellStyle BackColor="#FEFCEB" /> <SortedAscendingHeaderStyle BackColor="#AF0101" /> <SortedDescendingCellStyle BackColor="#F6F0C0" /> <SortedDescendingHeaderStyle BackColor="#7E0000" /> </asp:GridView> <asp:SqlDataSource ID="dsEnrolledBenefits" runat="server" ConnectionString="<%$ ConnectionStrings:PAYROLL %>" SelectCommand="DLI_BENEFITS_EMPLOYEE_ENROLLED" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="tbEMPLOYEE_ID" Name="EID" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> </div> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace DLI_EMPLOYEE_BENEFITS { public partial class EmployeeBenefits : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //if (!IsPostBack) //{ // lbEMPLOYEE_NAME.Text = ""; // tbEMPLOYEE_ID.Text = ""; //} ibINITIAL_DATE.Visible = false; lblSPMessageSuccess.Text = ""; string qsEmpID = Request.QueryString["qsEmpID"]; if (string.IsNullOrEmpty(qsEmpID)) { } else { tbEMPLOYEE_ID.Text = qsEmpID.ToUpper(); MyLookup(); } } protected void ibGET_Click(object sender, ImageClickEventArgs e) { MyLookup(); } private void MyLookup() { if (string.IsNullOrEmpty(tbEMPLOYEE_ID.Text)) { lbEMPLOYEE_NAME.Text = "INVALID EMPLOYEE ID"; } else { lbEMPLOYEE_NAME.Text = tbEMPLOYEE_ID.Text.ToUpper(); tbEMPLOYEE_ID.Text = tbEMPLOYEE_ID.Text.ToUpper(); int EmpID = -1; string constr = ConfigurationManager.ConnectionStrings["PAYROLL"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("DLI_BENEFITS_EMP_ID_VALIDATE")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmployeeID", tbEMPLOYEE_ID.Text.ToUpper()); cmd.Connection = con; con.Open(); EmpID = Convert.ToInt32(cmd.ExecuteScalar()); con.Close(); } } if (EmpID != -1) { using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("DLI_BENEFITS_HEADER")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmployeeID", tbEMPLOYEE_ID.Text.ToUpper()); cmd.Connection = con; con.Open(); SqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dataReader.Read()) { lbEMPLOYEE_NAME.Text = dataReader["EMPLOYEE_NAME"].ToString(); ddl401_TYPE.SelectedValue = dataReader["401K_TYPE"].ToString(); tb401_PCT.Text = dataReader["CONTRIBUTION_RATE_401K_PCT"].ToString(); tb401_AMOUNT.Text = dataReader["CONTRIBUTION_RATE_401K_AMOUNT"].ToString(); cbCOMP_LIFE_EMP.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_EMP"]); cbCOMP_LIFE_SPOUSE.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_SPOUSE"]); cbCOMP_LIFE_CHILDREN.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_CHILD"]); TbCOMP_LIFE_DEPENDENTS.Text = dataReader["COMPANY_LIFE_DEPENDENTS"].ToString(); cbDECLINE_HEALTH.Checked = Convert.ToBoolean(dataReader["HEALTH_DECLINE"]); cbDECLINE_DENTAL.Checked = Convert.ToBoolean(dataReader["DENTAL_DECLINE"]); cbDECLINE_VISION.Checked = Convert.ToBoolean(dataReader["VISION_DECLINE"]); cbDECLINE_LIFE.Checked = Convert.ToBoolean(dataReader["LIFE_DECLINE"]); tbNOTES.Text = dataReader["NOTES"].ToString(); lbENROLL_DATE.Text = Convert.ToDateTime(dataReader["ENROLL"]).ToString("MM/dd/yyyy"); lbHIRE_DATE.Text = Convert.ToDateTime(dataReader["HIRE_DATE"]).ToString("MM/dd/yyyy"); lbINITIAL_MEETING.Text = ""; ibINITIAL_DATE.Visible = true; if (dataReader["INIT_MEETING"].GetType() != typeof(DBNull)) { lbINITIAL_MEETING.Text = Convert.ToDateTime(dataReader["INIT_MEETING"]).ToString("MM/dd/yyyy"); ibINITIAL_DATE.Visible = false; } } con.Close(); } } } else { lbEMPLOYEE_NAME.Text = tbEMPLOYEE_ID.Text.ToUpper() + " is not valid."; } } } protected void ibUPDATE_HEADER_Click(object sender, ImageClickEventArgs e) { string @EMP_ID = Convert.ToString(tbEMPLOYEE_ID.Text).ToUpper(); string @K401_TYPE = Convert.ToString(ddl401_TYPE.SelectedValue).ToUpper(); string @NOTES = Convert.ToString(tbNOTES.Text).ToUpper(); string cnString = ConfigurationManager.ConnectionStrings["PAYROLL"].ConnectionString; //Response.Write(cnString); lblSPMessageSuccess.Text = ""; SqlConnection cn = null; try { cn = new SqlConnection(cnString); cn.Open(); SqlCommand cmd = new SqlCommand("DLI_BENEFITS_HEADER_UPDATE", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EMP_ID", @EMP_ID); cmd.Parameters.AddWithValue("@K401_TYPE", @K401_TYPE.ToString()); if (decimal.TryParse(tb401_AMOUNT.Text, out decimal parsed)) { cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_AMOUNT", decimal.Parse(tb401_AMOUNT.Text)); } else { cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_AMOUNT", DBNull.Value); } if (Int16.TryParse(tb401_PCT.Text, out Int16 parsed1)) { cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_PCT", Int16.Parse(tb401_PCT.Text)); } else { cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_PCT", DBNull.Value); } cmd.Parameters.AddWithValue("@COMPANY_LIFE_EMP", cbCOMP_LIFE_EMP.Checked); cmd.Parameters.AddWithValue("@COMPANY_LIFE_SPOUSE", cbCOMP_LIFE_SPOUSE.Checked); cmd.Parameters.AddWithValue("@COMPANY_LIFE_CHILD", cbCOMP_LIFE_CHILDREN.Checked); if (Int16.TryParse(TbCOMP_LIFE_DEPENDENTS.Text, out Int16 parsed2)) { cmd.Parameters.AddWithValue("@COMPANY_LIFE_DEPENDENTS", Int16.Parse(TbCOMP_LIFE_DEPENDENTS.Text)); } else { cmd.Parameters.AddWithValue("@COMPANY_LIFE_DEPENDENTS", DBNull.Value); } cmd.Parameters.AddWithValue("@HEALTH_DECLINE", cbDECLINE_HEALTH.Checked); cmd.Parameters.AddWithValue("@DENTAL_DECLINE", cbDECLINE_DENTAL.Checked); cmd.Parameters.AddWithValue("@VISION_DECLINE", cbDECLINE_VISION.Checked); cmd.Parameters.AddWithValue("@LIFE_DECLINE", cbDECLINE_LIFE.Checked); cmd.Parameters.AddWithValue("@NOTES", @NOTES.ToString()); cmd.Parameters.Add("@SP_MESSAGE", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output; cmd.Parameters.Add("@SP_ERROR_NUMBER", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); int output = (int)cmd.Parameters["@SP_ERROR_NUMBER"].Value; string output_message = (string)cmd.Parameters["@SP_MESSAGE"].Value; if (output == -1) { lblSPMessageSuccess.Text = ""; lblSPMessageError.Text = output_message; } else { lblSPMessageError.Text = ""; lblSPMessageSuccess.Text = output_message; //dsEnrolledBenefits.EnableCaching = false; //dsEnrolledBenefits.EnableCaching = true; //this.dsEnrolledBenefits.DataBind(); //this.gvOpenProjects.DataBind(); } } catch (Exception ex) { lblSPMessageError.Text = ex.Message; } finally { if (cn != null) { cn.Close(); MyLookup(); } } } } }
Any help is greatly appreciated.
Monday, July 22, 2019 8:32 PM
Answers
-
User475983607 posted
What I meant by change was on the textbox I entered at the end of MY RECORD NEW RECORD I added INFO WITH NEW NOTES HERE and on dependents I set it to 4 when the original value was 99.. when I hit update it ignored the changes I put in the textboxes and according to the SQL profiler submitted the information as if I hadn't changed anything.The symptom indicates a timing bug. The code is rebinding a server control (overwriting) before invoking the update. This can happen in the code if Request.QueryString["qsEmpID"] has a value.
protected void Page_Load(object sender, EventArgs e) { //if (!IsPostBack) //{ // lbEMPLOYEE_NAME.Text = ""; // tbEMPLOYEE_ID.Text = ""; //} ibINITIAL_DATE.Visible = false; lblSPMessageSuccess.Text = ""; string qsEmpID = Request.QueryString["qsEmpID"]; if (string.IsNullOrEmpty(qsEmpID)) { } else { tbEMPLOYEE_ID.Text = qsEmpID.ToUpper(); MyLookup(); } }
Please set a break point and single step through the logic.
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 23, 2019 3:19 PM
All replies
-
User-719153870 posted
Hi MarkSimons,
Your 'DLI_BENEFITS_HEADER_UPDATE' stored procedure is not given, so it's hard to determine where the problem is.
Had actually changed @COMPANY_LIFE_DEPENDENTS=99 to 4 and @NOTES to @NOTES=N'MY RECORD NEW RECORD INFO WITH NEW NOTES HERE'
If as you said, the values of @COMPANY_LIFE_DEPENDENTS and @NOTES changed, it means that your database connection is successful and the stored procedure is successfully executed.
Please provide your 'DLI_BENEFITS_HEADER_UPDATE' to help find the real problem.
Best Regard,
Yang Shen
Tuesday, July 23, 2019 3:27 AM -
User9396681 posted
What I meant by change was on the textbox I entered at the end of MY RECORD NEW RECORD I added INFO WITH NEW NOTES HERE and on dependents I set it to 4 when the original value was 99.. when I hit update it ignored the changes I put in the textboxes and according to the SQL profiler submitted the information as if I hadn't changed anything.
Sorry about not providing the SP code.
USE [PAYDEMO] GO /****** Object: StoredProcedure [dbo].[DLI_BENEFITS_HEADER_UPDATE] Script Date: 7/23/2019 8:46:39 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[DLI_BENEFITS_HEADER_UPDATE] @EMP_ID [varchar](15), @K401_TYPE [nvarchar](10), @CONTRIBUTION_RATE_401K_AMOUNT [decimal](12, 2), @CONTRIBUTION_RATE_401K_PCT [tinyint], @COMPANY_LIFE_EMP [bit], @COMPANY_LIFE_SPOUSE [bit], @COMPANY_LIFE_CHILD [bit], @COMPANY_LIFE_DEPENDENTS [tinyint], @HEALTH_DECLINE [bit], @DENTAL_DECLINE [bit], @VISION_DECLINE [bit], @LIFE_DECLINE [bit], @NOTES [nvarchar](max), @SP_MESSAGE varchar(200) OUTPUT, @SP_ERROR_NUMBER int OUTPUT AS BEGIN SET @SP_ERROR_NUMBER = 0 IF @SP_ERROR_NUMBER = 0 BEGIN UPDATE EMPLOYEE_PTO_401k SET [401K_TYPE] = @K401_TYPE, CONTRIBUTION_RATE_401K_AMOUNT = @CONTRIBUTION_RATE_401K_AMOUNT, CONTRIBUTION_RATE_401K_PCT = @CONTRIBUTION_RATE_401K_PCT, COMPANY_LIFE_EMP = @COMPANY_LIFE_EMP, COMPANY_LIFE_SPOUSE = @COMPANY_LIFE_SPOUSE, COMPANY_LIFE_CHILD = @COMPANY_LIFE_CHILD, COMPANY_LIFE_DEPENDENTS = @COMPANY_LIFE_DEPENDENTS, HEALTH_DECLINE = @HEALTH_DECLINE, DENTAL_DECLINE = @DENTAL_DECLINE, VISION_DECLINE = @VISION_DECLINE, LIFE_DECLINE = @LIFE_DECLINE, NOTES = @NOTES WHERE (EMP_ID = @EMP_ID) SELECT @SP_MESSAGE = 'RECORD UPDATED SUCCESSFULLY', @SP_ERROR_NUMBER = 0 END END
Thanks.
Tuesday, July 23, 2019 2:47 PM -
User475983607 posted
What I meant by change was on the textbox I entered at the end of MY RECORD NEW RECORD I added INFO WITH NEW NOTES HERE and on dependents I set it to 4 when the original value was 99.. when I hit update it ignored the changes I put in the textboxes and according to the SQL profiler submitted the information as if I hadn't changed anything.The symptom indicates a timing bug. The code is rebinding a server control (overwriting) before invoking the update. This can happen in the code if Request.QueryString["qsEmpID"] has a value.
protected void Page_Load(object sender, EventArgs e) { //if (!IsPostBack) //{ // lbEMPLOYEE_NAME.Text = ""; // tbEMPLOYEE_ID.Text = ""; //} ibINITIAL_DATE.Visible = false; lblSPMessageSuccess.Text = ""; string qsEmpID = Request.QueryString["qsEmpID"]; if (string.IsNullOrEmpty(qsEmpID)) { } else { tbEMPLOYEE_ID.Text = qsEmpID.ToUpper(); MyLookup(); } }
Please set a break point and single step through the logic.
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 23, 2019 3:19 PM -
User9396681 posted
That was it.. commented out the MyLookup() and did an update and it worked correctly.
Tuesday, July 23, 2019 4:17 PM -
User9396681 posted
Changed it to !IsPostBack
if (string.IsNullOrEmpty(qsEmpID)) { } else { tbEMPLOYEE_ID.Text = qsEmpID.ToUpper(); if (!IsPostBack) { MyLookup(); } }
Tuesday, July 23, 2019 8:58 PM