怎么判断数据库是否存在这个值

yehaomin 2009-04-09 09:06:58
如果我要判断数据库中是否存在这个值改怎么写
...全文
99 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
justin_wkf 2009-04-10
  • 打赏
  • 举报
回复
.
.
.
open;
If RecordCount > 0 Then
showmessage('NO ')
else
showmessage('YES')
yct0605 2009-04-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 Corn1 的回复:]
Delphi(Pascal) code
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from name1 where Field1=:UserInput');
Parameters.ParamByName('UserInput').Value := Edit1.Text;
Open;
if IsEmpty then
showmessage('NOT FOUND')
else
showmessage('FOUND');
end;
[/Quote]
查询后进行判断,这是最基本的了。
yuweihua86 2009-04-10
  • 打赏
  • 举报
回复
adoquery1.sql.Add('select name from name1 where name=''+Edit1.Text+''')

IsEmpty 提示

Corn1 2009-04-10
  • 打赏
  • 举报
回复

with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from name1 where Field1=:UserInput');
Parameters.ParamByName('UserInput').Value := Edit1.Text;
Open;
if IsEmpty then
showmessage('NOT FOUND')
else
showmessage('FOUND');
end;
taste品味 2009-04-10
  • 打赏
  • 举报
回复
SQL查询
genispan 2009-04-09
  • 打赏
  • 举报
回复

with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add(''select * from name1 where Field=:UserInput');
ExecSQL;
end;
if ADOQuery1.RecordCount=0 then
showmessage('NOT FOUND')
else
showmessage('FOUND');
yehaomin 2009-04-09
  • 打赏
  • 举报
回复
就是说如果我要判断数据库mb1的表name1中是否存在用户输入的这个值改怎么写
byteh 2009-04-09
  • 打赏
  • 举报
回复
SQL语句
提问笼统回答也只好如此
abcd_nonqq 2009-04-09
  • 打赏
  • 举报
回复
是什么值? 不可以用查询吗? TAble 查询与 query1 查询都可以呵,看相关书有关查询的就可以了.

2,495

社区成员

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

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