Link to home
Start Free TrialLog in
Avatar of stronghold888
stronghold888Flag for Canada

asked on

Transfer data from a MsAccess db to another via ODBC connection

Hi Experts,

I'm trying to figure how I can transfer data from a MsAccess database to another MsAccess database. I wanted to use VB and insert a SQL command to insert in the table the data and update the other data.

How I can do this?

Thanks
stronghold888
ASKER CERTIFIED SOLUTION
Avatar of SQL_SERVER_DBA
SQL_SERVER_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stronghold888

ASKER

Hi Sql_Server Dba,

This code need to be inserted in a module or just somewhere else?

Thanks

stronghold888
SOLUTION
Avatar of Shanmuga Sundaram D
Shanmuga Sundaram D
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm not that new to programming. It's just been a long time I stopped to program, that's why without practice, my SQL knowledge went down.

This will help. I don't know if it will work because most fields in the second database are different from the first. I will do this then come back if I encouter some problems.
Thanks

stronghold888
It did not worked. I made another attempt, so I linked the primary table from the database 1 to the second table. I think then it would be better to run a query, so I made this, but still don't work :(

INSERT INTO TblStatements(StatID, ActivityID, Calendar_E, Calendar_F, Directorate, Rel_Link, EMSQCode, StatReq, Stat_Applic, EMS_Item, CheckLink, CheckEms, CheckReq, SMEID, Comments, Rev_Stat)
SELECT  (StatID, ActivityID, Calendar_E, Calendar_F, Directorate, Rel_Link, EMSQCode, StatReq, Stat_Applic, EMS_Item, CheckLink, CheckEms, CheckReq, SMEID, Comments, Rev_Stat)
FROM Src_TblCalendar;

That was the INSERT, but need also to update and there I am completely lost

I was thinking about this:

SELECT SELECT  (StatID, ActivityID, Calendar_E, Calendar_F, Directorate, Rel_Link, EMSQCode, StatReq, Stat_Applic, EMS_Item, CheckLink, CheckEms, CheckReq, SMEID, Comments, Rev_Stat)
FROM Src_TblCalendar;
while NOT EOF    
     UPDATE TblStatements SET (StatID, ActivityID, Calendar_E, Calendar_F, Directorate, Rel_Link, EMSQCode, StatReq, Stat_Applic, EMS_Item, CheckLink, CheckEms, CheckReq, SMEID, Comments, Rev_Stat)
where PK = Same PK;
end loop

The structure in the first database is very different of the one in the other database even if most fields are the same.

stronghold888
save it in an xml file.
do you mean save the query in an xml file?
not xml file, sorry got you confused...

put it in a subroutine.
hmm...something like this:

 sub Update()
     dim sSQL as string
     sSQL = "UPDATE <THE NAME OF YOUR TABLE> SET <THE NAME OF YOUR TABLE>.<NAME OF THE FIELD THAT YOU WANT TO MODIFIED>= <VALUE>
WHERE (((<THE NAME OF YOUR TABLE>.<NAME OF THE FIELD THAT YOU WANT TO MODIFIED>)=<VALUE FILTER>))"

     codedb.execute sSQL
  end sub

If you refer to this, I'm not that sure it will really work :(