Solved

combining two databases

Posted on 1998-09-08
7
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 
LVL 14

Accepted Solution

by:
waty earned 100 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Script Host failed (Access is denied.) error 6 477
Send outlook email from VBS Script 2 67
Problem to line 23 80
Get the Y value of a line at X in a chart in VBA 28 73
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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 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