急???????

qyyok 2003-08-19 04:04:10
增加一条记录时,怎样检测数据库中是否有相同的记录。有相同的取消
...全文
100 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluespy 2003-08-19
  • 打赏
  • 举报
回复
可以数据库里设该字段唯一啊
OO_is_just_P 2003-08-19
  • 打赏
  • 举报
回复
procedure TForm1.DBISAMTable1BeforePost(DataSet: TDataSet);
begin
if Dataset.Lookup('Name','AAA','Name')=false then Abort;
end;
//=======================================================================
function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant; virtual;

Checks whether the dataset is unidirectional, and if so, raises an EDatabaseError exception.
Returns a Variant with the value False《找不到返回false》, indicating that a matching record was not found.

Descendant classes that are not unidirectional override this method so that it locates the record where the fields identified by the comma-delimited string KeyFields have the values specified by the Variant or Variant array KeyValues. In classes that implement Lookup, it returns a Variant or Variant array that contains the value or values of the fields specified by the comma-delimited string ResultFields on the specified record.
qyyok 2003-08-19
  • 打赏
  • 举报
回复
如何检测能给段代码吗,先谢了
Spqk005 2003-08-19
  • 打赏
  • 举报
回复
先检测

然后决定是否增加

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧