一个表中有字段“员工号”,其为主键。在delphi中可否实现他的唯一性检验?
若检测到不唯一时,提示请重新输入。我写的程序如下:
with DataModuleMain.Tab_employee do
begin
first;
while not eof do
begin
if DBEdit2.Text=FieldByName('员工号').Value then
ShowMessage('该员工号已经存在,请重新输入');
else
next;
end;
end;
我觉得这个办法很笨,更要命的是通不过,请大家指教。
谢谢。
若检测到不唯一时,提示请重新输入。我写的程序如下:
with DataModuleMain.Tab_employee do
begin
first;
while not eof do
begin
if DBEdit2.Text=FieldByName('员工号').Value then
ShowMessage('该员工号已经存在,请重新输入');
else
next;
end;
end;
我觉得这个办法很笨,更要命的是通不过,请大家指教。
谢谢。
解决方案 »
- 非常十分以及极其着急中,,,,,,,,,,,,,,,,,,,,,,,
- ●●●●谁知道dspack中怎么连接多个filter啊●●●●
- 一个SQL语言的简单的问题?
- 求助!简单技巧性问题
- 怎么判断组合键?
- 用什么方法修改用delphi写的,但已经编译了的from的title
- 制作安装程序的问题
- 如何在自己的程序中 下载百度 各种Top列表 中的歌曲
- 一个ListBox和一个Button,Button的OnClick事件是删除ListBox中选中的项目,怎么写这个事件?俺是新手!
- 如何实现sql语句复制数据表结构的?
- 用ADOQuery如何获得SQL执行后的返回值?
- 请问怎样用递归函数去除二值图象中的离散杂点??
begin
close;
sql.clear;
sql.add('select * from tablename where 员工号='''+dbedit2.text+'''');
try
open;
except
execsql;
end;
if recordcount>0 then
begin
ShowMessage('该员工号已经存在,请重新输入');
exit;
end;
end;