远程数据库存取控件TRemoteADO的示例代码:
//
// 读数据集请求…
procedure TForm1.Button6Click(Sender: TObject);
begin
remoteado1.TaskTimeout:=60;
RemoteADO1.ReadDataset('中国','SELECT * FROM NETDNA_LOCALNODES ORDER BY NODEID');
end;
//
// 写ClientDataset到远程…
procedure TForm1.Button5Click(Sender: TObject);
begin
RemoteADO1.WriteClientDataset('中国','NETDNA_LOCALNODES','NodeId',0,2,clientdataset1);
end;
//
// 写ADODataset到远程…
procedure TForm1.Button7Click(Sender: TObject);
begin
adoconnection1.Connected:=true;
adodataset1.CommandText:='select * from netdna_localnodes order by nodeid';
adodataset1.Active:=true;
RemoteADO1.WriteAdoDataset('中国','NETDNA_LOCALNODES','NodeId',0,2,adodataset1);
end;
//
// 远程运行SQL…
procedure TForm1.Button12Click(Sender: TObject);
begin
RemoteAdo1.ExecSQL('中国','SELECT COUNT(*) FROM NETDNA_LOCALNODES',1);
end;
//
// 运行SQL失败时…
procedure TForm1.RemoteADO1ExecSQLFail(Sender: TObject);
begin
memo1.lines.Add('运行SQL命令失败!');
end;
//
// 运行SQL成功时…
procedure TForm1.RemoteADO1ExecSQLSuccess(Sender: TObject;
aRetValue: String);
begin
memo1.lines.Add('运行SQL命令成功!返回='+aRetValue);
end;
//
// 读取数据集失败时…
procedure TForm1.RemoteADO1ReadDatasetFail(Sender: TObject);
begin
memo1.lines.Add('读数据集失败!');
end;
//
// 读取数据集成功时…
procedure TForm1.RemoteADO1ReadDatasetSuccess(Sender: TObject;
aCDS: TClientDataSet);
begin
memo1.lines.Add('读数据集成功!');
clientdataset1.Active:=false;
clientdataset1.Data:=acds.Data;
end;
//
// 写数据集失败时…
procedure TForm1.RemoteADO1WriteDatasetFail(Sender: TObject);
begin
memo1.lines.Add('写数据集失败!');
end;
//
// 写数据集成功时…
procedure TForm1.RemoteADO1WriteDatasetSuccess(Sender: TObject);
begin
memo1.lines.Add('写数据集成功!');
end;