在数据表中,KCSHL,KCXL,KCCQ,科目号4项都是int型的,其他都为char型,用下面的语句编译时出现下面所给的错误,请这段代码哪些地方错了,我花了一下午从网上找到这个加'''的方法,我一试却不行,请高手指点,在线等!
var
i1,i2,i3,i4:integer;
begin
i1:=strtoint(edit1.text);
i2:=strtoint(edit2.text);
i3:=strtoint(edit3.text);
i4:=strtoint(edit4.text);
with KCDM.qryNew do
begin
close;
sql.Clear;
sql.Add('insert into KC0(KCBM,KCMC,KCLB,KCDW,KCSHL,KCXL,KCGG,KCCQ,科目名,科目号)');
sql.Add('values('''+edtBM.Text+''','''+edtMC.Text+''','''+edtLB.Text+''','''+edtdw.Text+''','+i1+','+i2+','''+edtGG.Text+''','+i3+','''+edtKMMC.Text+''','+i4+')');
ExecSQL;
[Error] New.pas(540): Incompatible types: 'String' and 'Integer'
[Error] New.pas(540): Incompatible types: 'String' and 'Integer'
[Error] New.pas(540): Incompatible types: 'String' and 'Integer'
[Error] New.pas(540): Incompatible types
var
i1,i2,i3,i4:integer;
begin
i1:=strtoint(edit1.text);
i2:=strtoint(edit2.text);
i3:=strtoint(edit3.text);
i4:=strtoint(edit4.text);
with KCDM.qryNew do
begin
close;
sql.Clear;
sql.Add('insert into KC0(KCBM,KCMC,KCLB,KCDW,KCSHL,KCXL,KCGG,KCCQ,科目名,科目号)');
sql.Add('values('''+edtBM.Text+''','''+edtMC.Text+''','''+edtLB.Text+''','''+edtdw.Text+''','+i1+','+i2+','''+edtGG.Text+''','+i3+','''+edtKMMC.Text+''','+i4+')');
ExecSQL;
[Error] New.pas(540): Incompatible types: 'String' and 'Integer'
[Error] New.pas(540): Incompatible types: 'String' and 'Integer'
[Error] New.pas(540): Incompatible types: 'String' and 'Integer'
[Error] New.pas(540): Incompatible types
with KCDM.qryNew do
begin
close;
sql.Clear;
sql.Add('insert into KC0(KCBM,KCMC,KCLB,KCDW,KCSHL,KCXL,KCGG,KCCQ,科目名,科目号)');
sql.Add('values(:a,:b,:c,:e,:f,:g,:h,:i,:j);
paramters.parambyname('a').value:=edit1.text;
paramters.....................
.......................
ExecSQL;
sql.Add('values('''+edtBM.Text+''','''+edtMC.Text+''','''+edtLB.Text+''','''+edtdw.Text+''','+i1+',i2,'''+edtGG.Text+''',i3,'''+edtKMMC.Text+''',i4)');
with KCDM.qryNew do
begin
close;
sql.Clear;
sql.Add('insert into KC0(KCBM,KCMC,KCLB,KCDW,KCSHL,KCXL,KCGG,KCCQ,科目名,科目号)');
sql.Add('values('''+edtBM.Text+''','''+edtMC.Text+''','''+edtLB.Text+''','''+edtdw.Text+''','+edit1.text+','+edit2.text+','''+edtGG.Text+''','+edit3.text+','''+edtKMMC.Text+''','+edit4.text+')');
ExecSQL;
begin
with KCDM.qryNew do
begin
close;
sql.Clear;
sql.Add('insert into KC0(KCBM,KCMC,KCLB,KCDW,KCSHL,KCXL,KCGG,KCCQ,科目名,科目号)');
sql.Add('values('''+edtBM.Text+''','''+edtMC.Text+''','''+edtLB.Text+''','''+edtdw.Text+''','+trim(edit1.text)+','+trim(edit2.text)+','''+edtGG.Text+''','+trim(edit3.text)+','''+edtKMMC.Text+''','+trim(edit4.text)+')');
ExecSQL;