Overwriting data in database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mirainc
    New Member
    • Jul 2008
    • 34

    Overwriting data in database

    How can i overwrite data in database?
    As in it only saves one set of data..
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Use UPDATE statements. Or, DELETE, then INSERT.

    Other than that, I'm not really sure what you are asking.

    Comment

    • mirainc
      New Member
      • Jul 2008
      • 34

      #3
      Originally posted by insertAlias
      Use UPDATE statements. Or, DELETE, then INSERT.

      Other than that, I'm not really sure what you are asking.
      Hey there..
      What im asking is im trying to save only 1 set of data everytime..
      When a user saves a new data, it will overwrite the previous saved data..
      How can i achieve this..?
      You suggested the UPDATE statement..can give me a sample on how to do this?

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        So you will only have one row in a table at a time? Is that what you mean? Or do you want only one row per user? If you need to know how to use a DB in your .NET program, we have two articles about it in the Howtwos section.

        Comment

        • mirainc
          New Member
          • Jul 2008
          • 34

          #5
          Originally posted by insertAlias
          So you will only have one row in a table at a time? Is that what you mean? Or do you want only one row per user? If you need to know how to use a DB in your .NET program, we have two articles about it in the Howtwos section.
          Yes only one row/record in the table. Because i want the record to overwrite the previous one each time.

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            Originally posted by mirainc
            Yes only one row/record in the table. Because i want the record to overwrite the previous one each time.
            Well, that's easy enough. When you are ready to write the new values, you could execute a DELETE statement to delete the row, and an INSERT statement to add a new one, or you could use an UPDATE statement to update all the columns in place.




            Read both of these tutorials to find out how to do this. There are code samples.

            Comment

            • mirainc
              New Member
              • Jul 2008
              • 34

              #7
              Originally posted by insertAlias
              Well, that's easy enough. When you are ready to write the new values, you could execute a DELETE statement to delete the row, and an INSERT statement to add a new one, or you could use an UPDATE statement to update all the columns in place.




              Read both of these tutorials to find out how to do this. There are code samples.
              I tried it but keep getting error..
              Is there any way that you could guide me through it..
              Appreciate the help..

              Comment

              • Curtis Rutland
                Recognized Expert Specialist
                • Apr 2008
                • 3264

                #8
                Originally posted by mirainc
                I tried it but keep getting error..
                Is there any way that you could guide me through it..
                Appreciate the help..
                I'm sorry, but the tutoriala are guides.

                Post your relevant code, your error, and what line throws it.

                Comment

                • mirainc
                  New Member
                  • Jul 2008
                  • 34

                  #9
                  Originally posted by insertAlias
                  I'm sorry, but the tutoriala are guides.

                  Post your relevant code, your error, and what line throws it.
                  This is my update statement
                  UPDATE [CrucialDate] SET [AcadYr] = @AcadYr, [Semester] = @Semester, [RegDate] = @RegDate, [WithDate] = @WithDate, [ContactPerson] = @ContactPerson

                  Protected Sub SaveBtn_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles SaveBtn.Click

                  SqlDataSource1. Update()
                  End Sub
                  If i use this, there's null values..

                  Comment

                  • Curtis Rutland
                    Recognized Expert Specialist
                    • Apr 2008
                    • 3264

                    #10
                    You obviously haven't read either of the tutorials.

                    Read them first, rework your code, and come back if you still have problems.

                    Comment

                    Working...