如下代码问题。先执行Button2再执行Button1。分不够再加。unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBClient, MConnect, StdCtrls, Grids, DBGrids;type
TForm1 = class(TForm)
DCOMConnection1: TDCOMConnection;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var tmp: TClientDataSet;
begin
tmp:=TClientDataSet.Create(nil);
tmp.RemoteServer:=Clientdataset1.RemoteServer;
tmp.ProviderName:='remotedsp';
tmp.CommandText:='insert agreement (date,code) values (''2003-4-19'',''t001'')';
tmp.Execute; //出现“灾难性故障”错误
tmp.Free;
end;procedure TForm1.Button2Click(Sender: TObject);
var tmp: TClientDataSet;
begin
tmp:=TClientDataSet.Create(nil);
tmp.RemoteServer:=ClientDataSet1.RemoteServer;
tmp.ProviderName:='remotedsp';
tmp.CommandText:='select sim_name from sg_sales.dbo.id08 order by sim_name';
tmp.Open;
combobox1.Items.Clear;
while not tmp.Eof do
begin
combobox1.Items.Add(tmp['sim_name']);
tmp.Next;
end;
tmp.Close;
freeandnil(tmp);
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBClient, MConnect, StdCtrls, Grids, DBGrids;type
TForm1 = class(TForm)
DCOMConnection1: TDCOMConnection;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var tmp: TClientDataSet;
begin
tmp:=TClientDataSet.Create(nil);
tmp.RemoteServer:=Clientdataset1.RemoteServer;
tmp.ProviderName:='remotedsp';
tmp.CommandText:='insert agreement (date,code) values (''2003-4-19'',''t001'')';
tmp.Execute; //出现“灾难性故障”错误
tmp.Free;
end;procedure TForm1.Button2Click(Sender: TObject);
var tmp: TClientDataSet;
begin
tmp:=TClientDataSet.Create(nil);
tmp.RemoteServer:=ClientDataSet1.RemoteServer;
tmp.ProviderName:='remotedsp';
tmp.CommandText:='select sim_name from sg_sales.dbo.id08 order by sim_name';
tmp.Open;
combobox1.Items.Clear;
while not tmp.Eof do
begin
combobox1.Items.Add(tmp['sim_name']);
tmp.Next;
end;
tmp.Close;
freeandnil(tmp);
end;end.
解决方案 »
- delphi中fastreport开发activex报表时inf文件中不能把fr3文件拷到客户机上
- 求TreeView和Timer的全部属性与方法
- delphi怎么实现右键打开文件的功能?
- 关于开发年龄问题
- 关于Quickrep的两个问题?
- 可选打印问题!!!!
- Word程序处理
- delphi调用dll问题。
- 高手请进:Image上画一个Shape,在拖动Shape时怎样才能让它们不闪烁?急急。。。。
- 关于数据庫的一个问题
- 關於ADOQuery控件,為什麼只支持4位小數點呀,怎麼解決,很急喲
- 三层的系统, 由于不想在注册表里产生垃圾, 所以不使用com/dcom , 只好使用corba, 但是corba无法穿透防火墙, 有另外的什么办法吗? 比如 we
tmp.CommandText:='insert agreement (date,code) values (''2003-4-19'',''t001'')';
改为
tmp.CommandText:='select ...';
就没有问题。
tmp.CommandText:='insert agreement (date,code) values (''2003-4-19'',''t001'')';
改为
tmp.CommandText:='select ...';
就没有问题。
Parameters :/ProcessID:{D6DFC270-FF07-4BF7-A6E4-970C0BD27664}-- your application GUID
tmp:=tclientdataset.create(nil);
tmp.remoteserver:=...;
tmp.providername:=...;
tmp.commandtext:=...;
tmp.execute/tmp.open;
...
tmp.close;
tmp.remoteserver.close; //这一行必须加
freeandnil(tmp);