Saving Data when modified

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    Saving Data when modified

    Hi guys im stuck in vb08 again......

    Im trying to save the database after editing with a datagrid.
    It saves ok when a new record has been added but not when existing data has been modified.

    This is the code im using
    Code:
    Try
     Me.Validate()
     Me.Customerbindingsource.endedit()
     Me.customertableadapter.update(me.fortedataset1.Customers)
     msg("Data saved")
    Catch ex as exception
     Msg("saved Failed")
     e.cancel = True
    End try
    The error occurs on the Me.Customertabl eadapter.update (me.fortedatase t1.Customers) line
    The default error message is:
    "Update requires a valid updatecommand when passed datarow with modified rows"

    Any solution?

    Daniel(~_~)
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Check the Update Command for the Customeradapter .
    usually, "Update" Statements are not built automatically, you have to Create a New for Update with proper SQL Syntax..

    REgards
    Veena

    Comment

    • daniel aristidou
      Contributor
      • Aug 2007
      • 494

      #3
      Originally posted by QVeen72
      Hi,

      Check the Update Command for the Customeradapter .
      usually, "Update" Statements are not built automatically, you have to Create a New for Update with proper SQL Syntax..

      REgards
      Veena
      Then what does the
      Me.Customerstab leadapter.Update(etc)
      Do?

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        Post here , What is your Update SQL Statement...?
        May be, Update Statement is there but there is no proper "Where Conditions"..
        Its better if Where Condition is based on the PK of the table..

        REgards
        Veena

        Comment

        • daniel aristidou
          Contributor
          • Aug 2007
          • 494

          #5
          Originally posted by QVeen72
          Hi,

          Post here , What is your Update SQL Statement...?
          May be, Update Statement is there but there is no proper "Where Conditions"..
          Its better if Where Condition is based on the PK of the table..

          REgards
          Veena
          I cannot find a statement anywhere except for the fill data statement which is used to copy the records from the dataset to the adapter.

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Hi,

            Right-Click the adatpter object >> Edit Queries in dataSet Designer
            Select Adapter RightClick >> Add Queries >> Next >> Select OptionUpdate
            >> Next
            Check What is the Updte Statement..

            Regards
            Veena

            Comment

            • daniel aristidou
              Contributor
              • Aug 2007
              • 494

              #7
              Originally posted by QVeen72
              Hi,

              Right-Click the adatpter object >> Edit Queries in dataSet Designer
              Select Adapter RightClick >> Add Queries >> Next >> Select OptionUpdate
              >> Next
              Check What is the Updte Statement..

              Regards
              Veena
              The Update statement is simply "update"

              Comment

              • daniel aristidou
                Contributor
                • Aug 2007
                • 494

                #8
                Originally posted by daniel aristidou
                The Update statement is simply "update"
                But how do i enforce the statement

                Comment

                • daniel aristidou
                  Contributor
                  • Aug 2007
                  • 494

                  #9
                  Originally posted by daniel aristidou
                  But how do i enforce the statement
                  I moved on to this
                  Dim adpt as tableadapter
                  adpt.updatecomm and() But im stuck on that......it wont let me use it. and seems to return "Nothing"

                  Also as per The Sql Statment. I dont know sql at all. can some one help me create an update statement It says whenever i try ........."token line 1, tokenline to 25"

                  Comment

                  Working...