H
heron
Unregistered / Unconfirmed
GUEST, unregistred user!
为了防止产品编码重复,用以下代码:
procedure TData.Table1BeforePost(DataSet: TDataSet);
begin
Table1.Refresh;
condition := 'SELECT * FROM ":' + DataName + ':Table1" Where CP_ID="';
condition := condition + FL_Data.AChanPin.fieldbyname('CP_ID').AsString + '"';
Query1.close;
Query1.SQL.clear;
Query1.sql.add(condition);
Query1.prepare;
try
Query1.open
except
Query1.ExecSQL;
end;
if Query1.RecordCount > 1 then
begin
application.MessageBox(' 输入的编码重复!' + #13 + #13 + '请重新输入数据.' + #13 + #13 ,'警告',MB_OK );
Table1.Delete;
exit;
end;
end;
编译通过,运行时输入数据保存时提示“Stack overflow”,注释掉Table1.Refresh
则不再提示“Stack overflow”,为什么??
注释掉Table1.Refresh后,运行程序仍然不能防止CP_ID字段的数据重复,
谁能帮帮我?
procedure TData.Table1BeforePost(DataSet: TDataSet);
begin
Table1.Refresh;
condition := 'SELECT * FROM ":' + DataName + ':Table1" Where CP_ID="';
condition := condition + FL_Data.AChanPin.fieldbyname('CP_ID').AsString + '"';
Query1.close;
Query1.SQL.clear;
Query1.sql.add(condition);
Query1.prepare;
try
Query1.open
except
Query1.ExecSQL;
end;
if Query1.RecordCount > 1 then
begin
application.MessageBox(' 输入的编码重复!' + #13 + #13 + '请重新输入数据.' + #13 + #13 ,'警告',MB_OK );
Table1.Delete;
exit;
end;
end;
编译通过,运行时输入数据保存时提示“Stack overflow”,注释掉Table1.Refresh
则不再提示“Stack overflow”,为什么??
注释掉Table1.Refresh后,运行程序仍然不能防止CP_ID字段的数据重复,
谁能帮帮我?