Solved

combining two databases

Posted on 1998-09-08
7
212 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
A macro to Count the number of rows across all worksheets 3 95
MsgBox 2 55
Prevent user closing word document opened with VB6 6 74
Recommendation vb6 to vb.net or others 14 149
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

778 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