各位老大,请帮忙!(50分)

X

xbh2

Unregistered / Unconfirmed
GUEST, unregistred user!
笨人编写的一段插入数据的程序:
access+ado,其中“记录数”为索引字段

var number:integer;
begin
adoquery1.Last;
number:=adoquery1['记录数']+1;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('insert into 记录表');
adoquery1.SQL.Add('values ("'+inttostr(number)+'","'+datetostr(datetimepicker1.date)+'","'+combobox1.text+'","'+edit1.text+'","'+edit2.text+'","'+edit3.text+'","'+combobox2.text+'","'+edit4.text+'","'+input1.text+'");');
adoquery1.ExecSQL;
adoquery1.Active:=true;
end;
运行后错误,总是提示索引字段插入了重复值,但分析程序并没有插入重复值,这是为什么?
 
adoquery1.ExecSQL;就可以了
不要Active:=true一句,在这里相当于提交两次相同的语句,肯定出错
 
adoquery1.Active:=true; 这是去掉死死
 
跟踪以下你的程序,把Sql语句打印出来,肯定是你的程序的问题,
遇到问题要耐心查找,学会调试!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
874
import
I
顶部