I Need To Move a Record
from one Table in a
Database To another Table
I am using ado in vb 6.0 plz help me!

Recommended Answers

All 4 Replies

You didn't provide the table structures so I'll assume the tables have the same structure. I have no idea how much detail you need so I'll start with a little and you can ask for more as you need. If you have an ADODB.Connection object named con then you can move the record in two steps. Step 1 will copy the record and step 2 will delete the record from the source table. Because you have provided no details I can give only an example.

con.Execute("INSERT INTO Table2 SELECT * FROM Table1 WHERE SomeField = 'Some Value'")
con.Execute("DELETE FROM Table1 WHERE SomeField = 'Some Value'")

Of course, you should do error checking at each step to ensure that you don't delete the record if it fails to insert into Table2.

What I suggest is, firstly call the records from the First Table that you need to transfer on to a VB Form on to Text boxes or a ListView.Then save those records in the table you require. Then write the Deleting Codes on to the same Button Following the Saving Codes, to be executed from the previous table.

Just go into Access and create a query. Make sure that it works. Then plug the result into VB6. For how to create a query

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.