adoquery 用法
添加
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Insert Into Table1(Field1,Field2)')
SQL.Add(' Values(10,20)');
ExecSQL;
end;
修改
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Update Table1 Set Field1=20,Field2=30)')
ExecSQL;
end;
删除
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Delete From Table1')
SQL.Add(' Where Field1=20 and Field2=30');
ExecSQL;
end;
查询
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Select Field1,Field2 From Table1')
SQL.Add(' Where Field1=20 and Field2=30');
Open;
end;
添加:
with ADOQuery1 do
append;
。。。
post;
删除:
with ADOQuery1 do
delete(选择删除的记录);
修改:
with ADOQuery1 do
edit;
。。。。
post;
adotable1.Append; //添加
ADotable1.Fields.FieldByName('gxid1').Value:=gx;
adotable1.Post;
adotable1.delete; //删除
adotable1.edit; //修改
ADotable1.Fields.FieldByName('gxid1').Value:=gx;
adotable1.post;
WITHI adoquery do
begin//添加
adoquery.open;//motice set adoquery.sql
adoquery.append;//OR adoquery.insert;
fieldbyname(fieldname).asstring:=trim(edit1.text);
..
adoquery.post;
end;
删除:
adoquery.delete
修改:
adoquery.edit;
fieldbyname(fieldname).asstring:=trim(edit1.text);
有关细节可以参看帮助OR DEMO