棘手的问题,大家可以讨论~~~~~~~~~~~~(200分)

  • 主题发起人 zhhyoushen
  • 开始时间
Z

zhhyoushen

Unregistered / Unconfirmed
GUEST, unregistred user!
我需要在两个access数据库大量倒数据 语句如下(不要嫌长哦)
Gauge1.Max := 28;
//Gauge1.Position := Gauge1.Position + 1;
DM1.Qtemp1.DatabaseName := '';
DM1.Qtemp1.RequestLive := false;
try
Label1.Caption := '请稍后,正在进行数据筛选...';
DM1.Qtemp1.SQL.Clear; //清空会员表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:associator"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入会员
DM1.Qtemp1.SQL.Add('insert into ":DB2:associator"');
DM1.QTemp1.SQL.Add('select * from ":DB1:associator" Associator_1 where Associator_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空出版社表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:bookmaker"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入出版社
DM1.Qtemp1.SQL.Add('insert into ":DB2:bookmaker"');
DM1.QTemp1.SQL.Add('select * from ":DB1:bookmaker" bookmaker_1 where bookmaker_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空供货商表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:client"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入供货商
DM1.Qtemp1.SQL.Add('insert into ":DB2:client"');
DM1.QTemp1.SQL.Add('select * from ":DB1:client" client_1 where client_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空Goods表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:Goods"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入Goods
DM1.Qtemp1.SQL.Add('insert into ":DB2:Goods"');
DM1.QTemp1.SQL.Add('select * from ":DB1:Goods" Goods_1 where Goods_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空index表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:index"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入index
DM1.Qtemp1.SQL.Add('insert into ":DB2:index"');
DM1.QTemp1.SQL.Add('select * from ":DB1:index" index_1 where index_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空info_goods表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:info_goods"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入info_goods
DM1.Qtemp1.SQL.Add('insert into ":DB2:info_goods"');
DM1.QTemp1.SQL.Add('select * from ":DB1:info_goods" info_goods_1 where info_goods_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空list表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:list"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入list
DM1.Qtemp1.SQL.Add('insert into ":DB2:list"');
DM1.QTemp1.SQL.Add('select * from ":DB1:list" list_1 where list_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空person表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:person"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入person
DM1.Qtemp1.SQL.Add('insert into ":DB2:person"');
DM1.QTemp1.SQL.Add('select * from ":DB1:person" person_1 where person_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空price表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:price"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入price
DM1.Qtemp1.SQL.Add('insert into ":DB2:price"');
DM1.QTemp1.SQL.Add('select * from ":DB1:price" price_1 where price_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空remove表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:remove"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入remove
DM1.Qtemp1.SQL.Add('insert into ":DB2:remove"');
DM1.QTemp1.SQL.Add('select * from ":DB1:remove" remove_1 where remove_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空stock_in表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:stock_in"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入stock_in
DM1.Qtemp1.SQL.Add('insert into ":DB2:stock_in"');
DM1.QTemp1.SQL.Add('select * from ":DB1:stock_in" stock_in_1 where stock_in_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空stock_money表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:stock_money"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入stock_money
DM1.Qtemp1.SQL.Add('insert into ":DB2:stock_money"');
DM1.QTemp1.SQL.Add('select * from ":DB1:stock_money" stock_money_1 where stock_money_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空stock_out表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:stock_out"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入stock_out
DM1.Qtemp1.SQL.Add('insert into ":DB2:stock_out"');
DM1.QTemp1.SQL.Add('select * from ":DB1:stock_out" stock_out_1 where stock_out_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //清空Tint表
DM1.Qtemp1.SQL.Add('Delete from ":DB2:Tint"');
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

try
DM1.Qtemp1.SQL.Clear; //写入Tint
DM1.Qtemp1.SQL.Add('insert into ":DB2:Tint"');
DM1.QTemp1.SQL.Add('select * from ":DB1:Tint" Tint_1 where Tint_1.dupdate>:s1');
DM1.QTemp1.ParamByName('s1').asdatetime := Self.dUpdate;
Dm1.Qtemp1.ExecSQL;
finally
Gauge1.Position := Gauge1.Position + 1;
end;

分开运行没有问题,合起来运行就报错“access violation at address 4d9f562b in module'idodbc32.dll'”

没办法了,请各位帮忙看看
 
在每次CLEAR之前先CLOSE看看如何
不行的话单步调试一下这种问题一般并不难解决
 
用ADO试试
 
每次执行后
先DM1.Qtemp1.close;

别用try finally
改用try Except。
 
在Clear前应该先关闭打开的Qtemp1.Close;
 
TT , 我试过了,问题依旧,5~~~~~~~~~~~~~
 
你只是把query open不要execsql
 
sorry, 各位,原来是我DataBaseName 设置上出了一点问题。
问题已解决,各位把分平分了吧
 
顶部