Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

combining two databases

Posted on 1998-09-08
7
Medium Priority
?
220 Views
Last Modified: 2012-05-04
I've got two dBase IV databases (or actually user chooses them) and
1. I wanna chech that databases structures are same kind of that bases can be compined.
2. Then I wanna add one database to another so that there isn't any dublicates (or make a new one).

Example:
I've got one database where is datas from 1/1/1998 30/6/1998 and another where is data from 1/5/1998 to 31/7/1998. Then user can choose if he wanna update first database or update second database or make a new database where is datas from 1/1/1998 to 31/7/1998.

I guess I can some way open Recordset so that it chooses datas from both databases so that there isn't dublicates and then I have to make a new database where I copy those Recordsets datas? Or can I open recordset which chooses only datas from DB1 which aren't in DB2 and copy datas in the DB2 or vice versa?

Could give an example how to do this.

Thanks in advance!
0
Comment
Question by:majala
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1433562
One good solution is creating Insert SQL statment and execute them. If the insert has inserted, all is allright for you. If the insert fails, the rows was previously in the DB.

This is the fastest way to do.

on error resume next
DB.Execute "Insert into..."


0
 

Author Comment

by:majala
ID: 1433563
What kind of is that insert SQL statement?

Isn't that a little bit slow way? If there is 20 000 lines in a DB1 and I wanna add only last 50 from those lines to DB2, I have to still check all those 20 000 lines!
0
 

Author Comment

by:majala
ID: 1433564
What kind of is that insert SQL statement?

Isn't that a little bit slow way? If there is 20 000 lines in a DB1 and I wanna add only last 50 from those lines to DB2, I have to still check all those 20 000 lines!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Accepted Solution

by:
waty earned 300 total points
ID: 1433565
If you know wich records to add, you can add them directly. If you don't know wich are the records to add, this is the fastest way.

The SQL looks like
   sSQL = "Insert Into Spool (userid, print_group, ps_job, nomd, prenomd, "
   sSQL = sSQL & "batiment, etage, bureau, execution_time)"
   sSQL = sSQL & "VALUES (LPAD (to_char (" & Format(gnSequence, "0000") & "), 4, '0'), "
   sSQL = sSQL & "'" & clsDestinataire.sPrintGroup & "', '" & sJob & "', "
   sSQL = sSQL & "'" & clsDestinataire.sNomd & "', '" & clsDestinataire.sPrenomd & "', "
   sSQL = sSQL & "'" & clsDestinataire.sBatiment & "', '" & clsDestinataire.sEtage & "', "
   sSQL = sSQL & "'" & clsDestinataire.sBureau & "', sysdate) "

   DB.Execute sSQL

But before, you have to read the record to add.

NB : This is the fastest way to do with access, SQL Server, Oracle, but I have never tested it with DBase
0
 

Author Comment

by:majala
ID: 1433566
Looks kind of weird. Could give some explanations what those lines do (mean).
What are these: userid, print_group, ps_job, nomd, prenomd.

DB.Execute sSQL (is this DB my destination or target DB?)

Could this do any good?

Dim srcRS as Recordset
Dim destRS as Recordset
Dim SQL as string

SQL ="SELECT * FROM MyTable WHERE MyField = '"& srcRS("MyField) & "'"
set destRS = db.OpenRecordset(SQL)
0
 
LVL 14

Expert Comment

by:waty
ID: 1433567
Oops, I have taken this query from the current application I am working on. You don't have to care.

Give me the description of your table, and I will post the query you need to execute.

DB.Execute sSQL => DB is the destination DB

Give me also the complete SQL you use to retrieve the data.
SQL ="SELECT Field1, .... FROM MyTable WHERE MyField = '"& srcRS("MyField) & "'"
set destRS = db.OpenRecordset(SQL)

0
 

Author Comment

by:majala
ID: 1433568
Those table structures can chance, so I hope to get this work any kind of two dBase databases (of cource those two tables have to be similar).

Actually I don't have any complete SQL what I use to retrieve my data. There is also one thing, there is separated Date and Time fields in my database. So I guess one have to compare both fields before can be sure that those fields are different or similar.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question