with DataModule1 do
Begin
if not dm_TCPIPCon.Connected then
dm_TCPIPCon.Connected := True;
with com_cds do
Begin
if(ComboBoxAbsent_Time.Text='上午') then
TimeStr:='0'
else
TimeStr:='1';
//检查是否有重复记录
Temps:='select * from empl_present where Empl_ID='''
+EmplID+'''and Cur_Date='''
+EditCur_date.Text+''' and Absent_time='''
+TimeStr+'''';
com_cds.Close;
CommandText := temps ;
Memo1.Text:=Temps;
Open;
if RecordCount>0 then
begin
showMessage('数据库中存在相同记录。请检查字段是否正确!');
com_cds.Close;
end
else
begin
Temps:='insert into empl_present(empl_ID,cur_Date,time1,time2,absent_time,absent_info,desc1)values('''
+EmplID+''','''+EditCur_date.Text+''','''+EditTime1.Text+''','''+EditTime2.Text+''','''
+TimeStr+''','''
+ComboBoxAbsent_info.Text+''','''
+EditDesc.Text+''')';
com_cds.Close;
CommandText := temps ;
Memo1.Text:=Temps;
Execute;
end;//else 不存在记录
end;//DataSet
dm_TCPIPCon.Connected := False;
end;//dataModule
一开始用com_cds查询是否存在相同的记录,然后用com_cds插入新的记录,
就在插入新的时候,系统报错了“灾难性”的