Board index » delphi » BDE and ADO

BDE and ADO


2005-08-17 09:27:26 AM
delphi87
Dear All,
I have a question here but i don't know where do i post it. But I hope someone can assist me.
I have two databases. one is DBF table created on the local, and the other one is ADO
connected to MS SQL. I'd like to insert all the records from ADO into DBF using SQL
syntax. Can someone teach me how to do it? If transfer records from DBF to DBF, i have no
problem on this. But if ADO to DBF, i have no idea how to do it. Can I do it as follow? If not,
is there anyway/method to do it?
Example :
Query1.SQL.Add('insert into table');
Query1.SQL.Add('(fld1, fld2)');
ADOQuery1.SQL.Add('select fld1,fld2 from ADOtable');
ADOQuery1.Open;
Query1.ExecSQL;
I am really appreciate it if someone can help me to solve this problem. Thanks a lot.
lsg
 
 

Re:BDE and ADO

"lsg" <XXXX@XXXXX.COM>schreef in bericht
Quote

Dear All,
I have a question here but i don't know where do i post it. But I hope
someone can assist me.
I have two databases. one is DBF table created on the local, and the other
one is ADO
connected to MS SQL. I'd like to insert all the records from ADO into
DBF using SQL
syntax. Can someone teach me how to do it? If transfer records from DBF to
DBF, i have no
problem on this. But if ADO to DBF, i have no idea how to do it. Can I do
it as follow? If not,
is there anyway/method to do it?
Example :
Query1.SQL.Add('insert into table');
Query1.SQL.Add('(fld1, fld2)');
ADOQuery1.SQL.Add('select fld1,fld2 from ADOtable');
ADOQuery1.Open;
Query1.ExecSQL;

I am really appreciate it if someone can help me to solve this problem.
Thanks a lot.

lsg
No, you can not do it that way.
Fastest way to do it is using a datapump.
If you want to do it by hand, do something like this:
procedure Pump(DBF : string; ADO : string);
begin
Query1.SQL := 'insert into ' + DBF;
Query1.SQL.Add('(:fld1, :fld2)'); // mind the : before
the fieldnames
ADOQuery1.SQL := 'select fld1, fld2 from ' + ADO;
ADOQuery1.Open;
while not ADOQuery.Eof do
begin
Query1.Params[0].asString := ADOQuery.Fields[0].AsString; //or
other type
Query1.Params[1].AsInteger := ADOQuery.Fields[1].AsInteger; // or
other type
Query1.ExecSQL;
ADOQuery.Next;
end;
end;
I didn't checked the syntax, so be aware of mistakes. I thik you get the
idea.
Hope this helps.
Alfred.