with MDataForm.NewADOQuery1 do
begin
close;
SQl.Clear;
sql.Add('insert into sh.VIOLATETYPE(违章编号,违章名称,处罚金额) values (:违章编号,:违章名称,:处罚金额)');
Parameters.ParamByName('违章编号').Value := trim(Edit1.Text);
Parameters.ParamByName('违章名称').Value := trim(ComboBox2.Text);
if ComboBox2.ItemIndex = 0 then Parameters.ParamByName('处罚金额').Value := 100.01;
if ComboBox2.ItemIndex = 1 then Parameters.ParamByName('处罚金额').Value := 200.00;
ExecSQL;
close;
end;
就这段代码,其中‘处罚金额’的字段为NUMBER,长度为8,小数点以后两位。数据库是oracle9i,总是执行到这里就不能正确运行,大家帮我分析一下。
begin
close;
SQl.Clear;
sql.Add('insert into sh.VIOLATETYPE(违章编号,违章名称,处罚金额) values (:违章编号,:违章名称,:处罚金额)');
Parameters.ParamByName('违章编号').Value := trim(Edit1.Text);
Parameters.ParamByName('违章名称').Value := trim(ComboBox2.Text);
if ComboBox2.ItemIndex = 0 then Parameters.ParamByName('处罚金额').Value := 100.01;
if ComboBox2.ItemIndex = 1 then Parameters.ParamByName('处罚金额').Value := 200.00;
ExecSQL;
close;
end;
就这段代码,其中‘处罚金额’的字段为NUMBER,长度为8,小数点以后两位。数据库是oracle9i,总是执行到这里就不能正确运行,大家帮我分析一下。
是不是应该这么写啊
EVariantInvalidOpError with message 'Invalid variant operation'............
var
S: String;
begin
S := 'INSERT INTO sh.VIOLATETYPE(违章编号,违章名称,处罚金额)VALUES(' +
Edit1.Text + ',''' +
ComboBox2.Text + ''',';
case ComboBox2.ItemIndex of
0: S := S + '100.01';
1: S := S + '200.00';
2: ...
3: ...
else
...
end;
S := S + ')';
AdoConn.Execute(S);
end;