Solved

Copying an Access table with DAO

Posted on 1998-11-11
14
288 Views
Last Modified: 2010-04-04
I am trying to copy an Access table (DAO 3.5). There are several ways to do this, but I must point out that I am using Titan Access for Delphi 3 and so any BDE usage is out of the question. However, Titan does provide the same functions as the BDE, although the DbiCreateTable function is not implemented.

Anyhow!

I have tried the following:

1. DAO "CopyObject" method. When I try this, the error message "OLE Automation Server does not support the CopyObject method." occurs. Has anybody managed to get this working?

2. BDE DbiCopyTable command. Because I am not using the BDE, but Titan, the error message "Engine not initialised" occurs, not surprisingly.

3. Titan's AccCopyTable method, which is identical to the BDE DbiCopyTable command. Error message: "DBIERR_NOTSUPPORTED". This is presumably because the Dbi_CreateTable command is not implemented as stated above, and I'm guessing that when copying a table, the CreateTable method is called first.

4. The actual TTable.CreateTable method. Nothing happens. No error message, no hanging, just nothing. When I step through the code, it just stops on that line but doesn't hang. I can still use the application.

5. The TTable.BatchMove method. See 4.

Anyone? I reckon the DAO CopyObject method MUST work somehow, but I'm not sure why delphi teels me it doesn't support it? Surely if I am using the OLE to talk to Access, then any Access commands should work. I used the CompactDatabase method and that worked fine.
0
Comment
Question by:jsweby
  • 8
  • 5
14 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346559
hi jsweby,

i don't know nothing about titan access, but maybe it could be solved with an sql statement like this:

Query1.Close;
Query1.SQL.Clear;
{ Create new Table and Copy Data }
Query1.SQL.Add('Select * into YourDestinationTable from YourSourceTable');
Try
  Query1.ExecSQL;
Except
   { Problem Occured }
End;

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346560
Hello? Is somebody here?
0
 
LVL 4

Author Comment

by:jsweby
ID: 1346561
Sorry, I wasn't emailed that you had replied first time!

I've actually got around this using a method similar to yours but it doesn't answer my original question, which is why can't I use the DAO's CopyObject method in Delphi?

Thanks though.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346562
hi jsweby,

its am alternate method. why you cannot use DAO's CopyObject i cannot answer, because i have no knowledge about titan access. Maybe it is really not supported.

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346563
hi jsweby,

its an alternate method. why you cannot use DAO's CopyObject i cannot answer, because i have no knowledge about titan access. Maybe it is really not supported.

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346564
Hello?
0
 
LVL 4

Author Comment

by:jsweby
ID: 1346565
I tried using the CopyObject method but Delphi says it is not supported by the OLE Automation Server. I don't understand that, I thought the OLE just did whatever the underlying application wanted.

I'm sorry for the lack of reply here, but the "Check here..." box is ticked but I'm not being emailed.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 44

Expert Comment

by:bruintje
ID: 1346566
Hi Jsweby,

Looking through this pile of open questions,

My answer> No, If the method isn't supported you can't make the call. I used to have similar problems automating Office stuff, for example

With a Word obj you can't do objWord.Font = blue or something but have to call something like objWord.Selection = blue.

So even if the font is a property in Word you have climb down the tree and call a method or property through the tree and tweaks.
So CopyObject isn't supported but another method is, or maybe you have to look through the object model to search where the method you want to use is being implemented.

Hope this helps
:O)Bruintje
0
 
LVL 4

Author Comment

by:jsweby
ID: 1346567
bruintje,

Thanks for the comment, I'm sure you are right about not all methods being supported, although I don't really get this because the OLE server should just deal with whatever the underlying application can deal with, surely?

Anyway, I've tried looking around for other methods and in the end I decided to copy tables the hard way, i.e. creating a duplicate of the table I want to copy and copying all the fields and records across one by one. Slow and not pretty, but thanks to the OLE not supporting CopyObject and thanks to Titan not supporting the BDE's CopyTable method, not much choice left!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346568
Hi jsweby,

have you tried my first comment, before you copying field by field and record for record?

meikl
0
 
LVL 4

Author Comment

by:jsweby
ID: 1346569
meikl,

Yes, thanks, that is effectively what I am doing.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346570
Hi  jsweby,

what will you do with the q, delete it or give me the points or give the points bruintje, or keep it alive?

meikl
0
 
LVL 4

Author Comment

by:jsweby
ID: 1346571
Make an answer & I'll give the points. First come...
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 1346572
ok jsweby,

here is it.
best luck.

meikl ;-)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

9 Experts available now in Live!

Get 1:1 Help Now