Databse refresh from dataset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xxsodapopxx5
    New Member
    • Dec 2006
    • 22

    Databse refresh from dataset

    Hello all, i am having a problem deleting a record from the database, i can get it to delete from the dataset with this code.
    Code:
                       
                 Try
                       DsAutoTech.ROMaster.Rows(Me.BindingContext(ROMasterBindingSource).Position).Delete()
                       DsAutoTech.AcceptChanges()
    
    
                       
                 Catch ex As Exception
                       MsgBox(ex.Message)
                 End Try
    On my form i have about 30 fields bound to datafields in a database.
    It is deleted from the dataset, when i am navigating with my form the data is deleted, but if i look in the databse it is still there. What code would i need to add to "Update" or "Refresh" my database with the new data?

    this is in .net 2005 thanks in advance
  • siricharan82
    New Member
    • Sep 2006
    • 20

    #2
    while deleting row from the dataset u have to update the dataset
    to the database and then u retreving the data freshlly

    while updating dataset to database
    use

    command builder this will write the queries for the records which have been
    changed

    i.e

    ***dim cmd as new [sql or oledb or any provider ur using]commandbuilder (dataadapter object)


    after that write

    ***[dataadapter object].update( DsAutoTech)





    Try
    DsAutoTech.ROMa ster.Rows(Me.Bi ndingContext(RO Maste rBindingSource) .Position).Dele te()
    DsAutoTech.Acce ptChanges()

    ************try the above code here(i.e *** ) ********


    Catch ex As Exception
    MsgBox(ex.Messa ge)
    End Try

    Comment

    • xxsodapopxx5
      New Member
      • Dec 2006
      • 22

      #3
      thanks for your response
      ok i tridd that code so now it reads...

      Code:
         Try
                          'DsAutoTech.ROMaster.Rows(Me.BindingContext(DsAutoTech, "ROMaster").Position).Delete()
                          DsAutoTech.ROMaster.Rows.RemoveAt(Me.BindingContext("ROMaster").Position + 1)
                          DsAutoTech.AcceptChanges()
                          ROMasterTableAdapter.Update(DsAutoTech)
                          DisplayRecordPosition()
                      Catch ex As Exception
                          MsgBox(ex.Message)
                      End Try
                  End If
      i went through a full debug and it appears to work, but still when i go into the database the record is still there...

      i still need to find a way to update the database with the data from the dataset.

      Comment

      • supunf
        New Member
        • Dec 2006
        • 6

        #4
        Hi,

        have u got a solution? what u need to do is you need to call the update
        method of the data adapter and then only call the data set's accept changes
        method.

        rgds

        Supun

        Comment

        Working...