ado,access,thread(30分)

  • 主题发起人 主题发起人 coolingxyz
  • 开始时间 开始时间
C

coolingxyz

Unregistered / Unconfirmed
GUEST, unregistred user!
CoInitialize(nil);
//初始化
AcHistory := TADOConnection.Create(nil);
AcHistory.ConnectionString := con;
AqHistory := TADOQuery.Create(nil);
AqHistory.Connection := AcHistory;
sql.Add('Insert into history(day, time, [Fh_id], type, info, alert) values(:myDay, :myTime, :fhid, :type, :info, :alert)');
AqHistory.Parameters.ParamByName('myDay').Value := FormatDateTime('yyyy-mm-dd', now());
AqHistory.Parameters.ParamByName('myTime').Value := FormatDateTime('hh:mm:ss', now());
AqHistory.Parameters.ParamByName('fhid').Value := DBID;
AqHistory.Parameters.ParamByName('type').Value := leixing;
AqHistory.Parameters.ParamByName('info').Value := info;
AqHistory.Parameters.ParamByName('alert').Value := Alt;
try
AcHistory.Open;
ExecSQL;
Except
exit;
end;
AcHistory.Close;
close;
Aqhistory.Free;
//free
AcHistory.Free;
CoUninitialize;

我这么写,但老是提示出错。
当我把sql语句改为sql.add('select * from history')时,没有提示出错,但没有返回数据集。
这是为什么,是不是我写的代码还缺少什么关键的东西?
 
加一个with AqHistory
begin
end;
 
多人接受答案了。
 
后退
顶部