prob in updation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srig
    New Member
    • Feb 2009
    • 11

    prob in updation

    hi all..
    im creatin form in visual studio 2005 for employee details.i hav created form for update.. wen i update only particular details other details become empty as i leave d text box blank.. already data get erased..pls help me out in solvin tis issue

    Thanks
    sri
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Either required data before submission or check when posting whether textboxes have values then update.

    Comment

    • srig
      New Member
      • Feb 2009
      • 11

      #3
      thanks a lot:)

      Regards
      sri

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Precisely, add validation to ensure that the user has entered all required data.

        You could also modify your code to dynamically create an SQL Update query which takes into consideration fields left empty....only update fields that have data provided.

        Comment

        • srig
          New Member
          • Feb 2009
          • 11

          #5
          i ll try it out..thanks:)
          can u tel me a good material or link for programming in vs.. bcoz im a beginner..
          im tryin to do programs now ly.

          Regards
          sri

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            When the user clicks the button to save the employee details check to make sure that all the employee data exists before updating the database.

            It's as simple as adding:

            Code:
            If(String.IsNullOrEmpty(myEmployeeInfo.Text)
            {
               myErrorLabel.Text = "Please supply the employee info";
            }
            Else
            {
               //preform database update
            }
            If there's a lot of fields to check, then consider doing the validation in a method that returns whether or not the input is valid. If this method returns true, then proceed with the database update, otherwise inform the user that they must provide data:

            Code:
                    private Boolean ValidateInput()
                    {   Boolean dataIsValid;
                        If(String.IsNullOrEmpty(myEmployeeInfo.Text)
                        {    dataIsValid = false;
                              myErrorLabel.Text = "Please supply the employee info";
                        }
                        Else
                        {     dataIsValid = true; }
                        return dataIsValid;
                     }

            Comment

            Working...