Solved

combining two databases

Posted on 1998-09-08
7
211 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now