Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

save a row in a table when the same is deleted in another table

NitheeshNitheesh Posts: 7Member
hai
how to save a row in a table when the same is deleted in another table in sql server.

i am doing a project in vb.net. i am using a table called entry and a table called garbag.
when i delete a row in the table entry it must automatically be saved in the table garbag.

is it possible?

how do i code it?

pls help me.

i am new to vb.net.

thanks .

Comments

  • jbassmanpjbassmanp Posts: 160Member
    : hai
    : how to save a row in a table when the same is deleted in another table in sql server.
    :
    : i am doing a project in vb.net. i am using a table called entry and a table called garbag.
    : when i delete a row in the table entry it must automatically be saved in the table garbag.
    :
    : is it possible?
    :
    : how do i code it?
    :
    : pls help me.
    : i am new to vb.net.
    :
    : thanks .
    :
    This will be a simple example you will have to fill in the details
    MainData will be the name of the Database
    open the Entry table if not already open record 10 will be deleted
    -- fields are Name, Address, State and Zip
    dr=BindingContext(maindatadataset."entry").position this gets the position 10 for the rec. set to delete

    Open the garbag table

    rec=MainData.Garbag.count ' this gets the num. of record in garbag ie 100
    rec=rec+1 ' this becomes 101
    maindatadataset.garbag.add ' this set up an add condition
    maindatadataset.garbag.rows(rec)("Name") = maindatadataset.entry.rows(dr)("Name")

    maindatadataset.garbag.rows(rec)("Address") = maindatadataset.entry.rows(dr)("Address")

    maindatadataset.garbag.rows(rec)("City") = maindatadataset.entry.rows(dr)("City")

    maindatadataset.garbag.rows(rec)("Zip") = maindatadataset.entry.rows(dr)("Zip")
    '' this get the data in those field to the garbag fields

    Garbagtableadapter.Update(maindatadataset.garbag) ' this saves the data to the new filed

    You can now go ahead and finish your deletion of the tenth record in the Entry table.
    I've made this crude and simple but it works with any data base (Access,Sql,Oracle etc. etc.) Good luck.. Read up on some database theory.....

    Good Coding....



Sign In or Register to comment.