本文整理自网络,侵删。
//查询记录procedure TForm1.Button1Click(Sender: TObject);beginADOQuery.Close;ADOQuery.SQL.Clear;ADOQuery.SQL.Add('se lect * from YourTABLE where 查询条件');ADOQuery.Open; //插入记录procedure TForm1.Button2Click(Sender: TObject);beginADOQuery.Close;ADOQuery.SQL.Clear;ADOQuery.SQL.Text:='ins ert into YourTABLE(字段1,字段2) values(:字段1,:字段2)';// ADOQuery.SQL.Add('ins ert into YourTABLE values(:字段1)');ADOQuery.Parameters.ParamByName('字段1').Value:=trim(Edit1.Text);ADOQuery.Parameters.ParamByName('字段2').Value:=trim(Edit2.Text);ADOQuery.ExecSQL;end;//删除记录procedure TForm1.Button3Click(Sender: TObject);beginADOQuery.Close;ADOQuery.SQL.Clear;ADOQuery.SQL.Text:='Del ete from YourTABLE where 字段3=:字段3';//这里没有添加where的条件判断,实际使用时,注意添加判断// ADOQuery.SQL.Add('De lete from NEW_TABLE where 字段3=:字段3');ADOQuery.Parameters.ParamByName('字段3').Value:=trim(Edit3.Text);ADOQuery.ExecSQL;//删除记录也可用DeleteRecords()函数procedure DeleteRecords(AffectRecords: TAffectRecords = arAll); 这个函数有一个参数:AffectRecords可以取如下的值: 1、arCurrent :删除当前记录 2、arFiltered :删除符合Filter过滤后的所有记录(如果你使用Filter过滤的话) 3、arAll :删除所有记录 4、arAllChapters :Delete affects all chapters(ADO chapters)//修改记录procedure TForm1.Button4Click(Sender: TObject);beginADOQuery.Close;ADOQuery.SQL.Clear;ADOQuery.SQL.Text:='Upd ate YourTABLE SET 字段4=:字段4';//这里没有添加where的条件判断,实际使用时,注意添加判断// ADOQuery.SQL.Add('Upd ate YourTABLE SET 字段4=:字段4');ADOQuery.Parameters.ParamByName('字段4').Value:=trim(Edit4.Text);ADOQuery.ExecSQL;//即时更新插入、删除、修改后的记录在上面插入、删除、修改的语句后添加如下代码即可:ADOQuery.Close;ADOQuery.SQL.Add('sele ct * from YourTABLE where 查询条件');ADOQuery.Open;//使用ADOQuery时注意:
相关阅读 >>
Delphi 查看字符串在不同编码(ascii、unicode、utf7、utf8、default、bigendianunicode)下的 hex
ttreeview的两个事件ondragdrop、ondragover 实现自动拖放功能
Delphixe4 版本中,已针对移动平台 引入了 arc 模型
更多相关阅读请进入《Delphi》频道 >>