在ADOTAble中进行查询,删除操作
程序员文章站
2022-03-03 13:53:24
...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, DBCtrls, Grids, DBGrids, DB, ADODB;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
DataSource1: TDataSource;
DBEdit1: TDBEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
DBGrid1: TDBGrid;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
newstring:string;
begin
inputQuery('输入查询条件','姓名为',newstring);
self.ADOTable1.Locate('Sname',newstring,[loCaseInsensitive]) //精确查询
end;
procedure TForm1.Button2Click(Sender: TObject);
var
newstring:string;
begin
inputQuery('输入查询条件','姓名为',newstring);
self.ADOTable1.Locate('Sname',newstring,[loPartialKey]) //模糊查询
end;
procedure TForm1.Button3Click(Sender: TObject);
var
newstring:string;
begin
inputQuery('输入查询条件','姓名为',newstring);
self.ADOTable1.Filter:='Sname='+''''+newstring+'''';
self.ADOTable1.Filtered:=true;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
newstring:string;
begin
inputQuery('输入查询条件','姓名为',newstring);
self.ADOTable1.Filter:='Sname like ' + ''''+'%'+newstring+'%'+'''';
self.ADOTable1.Filtered:=true;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
self.ADOTable1.DisableControls;
if
messageDlg('确实要删除这条记录吗?',mtinformation,[mbok,mbcancel],0)=mrOk
then
self.ADOTable1.Delete;
self.ADOTable1.EnableControls;
end;
end.
推荐阅读
-
SqlServer2005中使用row_number()在一个查询中删除重复记录的方法
-
Winform中怎样在工具类中对窗体中多个控件进行操作(赋值)
-
SqlServer 2005中使用row_number()在一个查询中删除重复记录
-
在Word2007中进行复制、剪切和粘贴操作
-
在SQL server 2008 R2进行数据查询操作时提示 “对象名无效”的问题
-
使用nodeJS中的fs模块对文件及目录进行读写,删除,追加,等操作详解
-
python中dict字典的查询键值对 遍历 排序 创建 访问 更新 删除基础操作方法
-
在windows操作系统中,查询端口占用和清除端口占用的程序
-
PHP中MongoDB数据库的连接、添加、修改、查询、删除等操作实例
-
Oracle数据库中的级联查询、级联删除、级联更新操作教程