PDA

Click to See Complete Forum and Search --> : Anyone have an idea how i can use vb to update an existing database?


Spawny
Sep 12th, 1999, 04:23 PM
Hi, I have an existing VB project that I have given to a user to test out. What I want to know is how do I update /upgrade the existing database if the user is already using an older version of the database. So, how can I extract the existing data from the old database and add it to the newly changed database with a few extra fields etc through VB. I need to gather atleast 2 tables from the old database and add them to the new one. These include the data from a 'Clients' table and a 'Results' table. Is it possible? and if so How and how do i cod e it? Thanks in advance to any help given.

Mike


[This message has been edited by Spawny (edited 09-13-1999).]

preeti
Sep 12th, 1999, 10:00 PM
Hi,

If the fields in the new database are not required fields (as in they can have null values) then what you could do is open two connections: one for the old database, and one for the new database. Select all your records from the each table (this can be done one at a time) then using a loop, insert each record into the new table

do until recordset.eof
sql = "INSERT INTO tablename (field names) VALUES (" & recordset(field1) & "," & recordset(field2) & ")"
newdb.execute(sql)
recordset.movenext
loop

field1 and field2 are the names of the fields in the old database.

Hope this helps,
Preeti