一. 在单步执行的时候,遇见adotable.open就会提示如下错误:
project PYKBZ.exe raised execption class EVariantInvalidOpError with message 'Invalid variant operation'.process stopped.Use Step or Run to continue.
我在delphi 6 中没有遇见过这种问题
到是7。*(*))()(·+——·##
二. 关于locate方法,代码如下:
if Button12.Hint = '0' then begin //添加
ADOT_YKSDSB.Append;
end;
if Button12.Hint = '1' then //修改
if not ADOT_YKSDSB.Locate('ywbh;xh', VarArrayOf([ywbh, Trim(E_XH5.Text)]),[]) then begin
ShowMsg('请先选择要修改的数据');
exit;end
else ADOT_YKSDSB.Edit;
end;
多次交叉执行以后就会报错,错误如下:
project PYKBZ.exe raised exception class EOleException with message '多步操作产生错误。请检查每一步的状态值。'.
project PYKBZ.exe raised execption class EVariantInvalidOpError with message 'Invalid variant operation'.process stopped.Use Step or Run to continue.
我在delphi 6 中没有遇见过这种问题
到是7。*(*))()(·+——·##
二. 关于locate方法,代码如下:
if Button12.Hint = '0' then begin //添加
ADOT_YKSDSB.Append;
end;
if Button12.Hint = '1' then //修改
if not ADOT_YKSDSB.Locate('ywbh;xh', VarArrayOf([ywbh, Trim(E_XH5.Text)]),[]) then begin
ShowMsg('请先选择要修改的数据');
exit;end
else ADOT_YKSDSB.Edit;
end;
多次交叉执行以后就会报错,错误如下:
project PYKBZ.exe raised exception class EOleException with message '多步操作产生错误。请检查每一步的状态值。'.
不能在编辑了
if Button12.Hint = '0' then begin //添加
ADOT_YKSDSB.Append;//((在编辑状态))
end;
if Button12.Hint = '1' then //修改
if not ADOT_YKSDSB.Locate('ywbh;xh', VarArrayOf([ywbh, Trim(E_XH5.Text)]),[]) then begin
ShowMsg('请先选择要修改的数据');
exit;end
else ADOT_YKSDSB.Edit;((在编辑状态))
end;
还有我是执行了n次成功后才发生错误的。全部的代码如下:
try
if Button12.Hint = '0' then begin //添加
ADOT_YKSDSB.Append;
end;
if Button12.Hint = '1' then //修改
if not ADOT_YKSDSB.Locate('ywbh;xh', VarArrayOf([ywbh, Trim(E_XH5.Text)]),[]) then begin
ShowMsg('请先选择要修改的数据');
exit;end
else ADOT_YKSDSB.Edit;
ADOT_YKSDSB.FieldByName('YWBH').AsString := Trim(E_YWBH5.Text);
ADOT_YKSDSB.FieldByName('GDSDM').Value := Trim(E_GDS5.Hint);
ADOT_YKSDSB.FieldByName('CDM').Value := Trim(E_CMC5.Hint);
ADOT_YKSDSB.FieldByName('XH').AsString := Trim(E_XH5.Text);
ADOT_YKSDSB.FieldByName('BZLBDM').AsString := Trim(E_BZLB5.Hint);
ADOT_YKSDSB.FieldByName('BZTS').Value := Trim(E_BZTS.Text);
ADOT_YKSDSB.FieldByName('BZRL').AsString := Trim(E_BZRL.Text);
ADOT_YKSDSB.FieldByName('BZ').AsString := Trim(E_NOTE5.Text);
ADOT_YKSDSB.Post;
ShowMsg('保存数据成功!');
ADOQ_YKSDSB.Close;
ADOQ_YKSDSB.SQL.Clear;
ADOQ_YKSDSB.SQL.Add(SQLYKSDSB);
ADOQ_YKSDSB.Parameters.ParamByName('ywbh').Value := ywbh;
ADOQ_YKSDSB.Open;
except
ShowMsg('保存数据出错!');
end;
except
ADOQ_YKSDSB.Cancel;
ShowMsg('保存数据出错!');
end;
就将就着看吧,很简单的,后面的给字段赋值的其实不要看,不关他们的事。
try
if Button12.Hint = '0' then begin //添加
ADOT_YKSDSB.Append;
end;
if Button12.Hint = '1' then //修改
if not ADOT_YKSDSB.Locate('ywbh;xh', VarArrayOf([ywbh, Trim(E_XH5.Text)]),[]) then begin
ShowMsg('请先选择要修改的数据');
exit;end
else ADOT_YKSDSB.Edit;
with ADOT_YKSDSB do
FieldByName('YWBH').AsString := Trim(E_YWBH5.Text);
FieldByName('GDSDM').Value := Trim(E_GDS5.Hint);
FieldByName('CDM').Value := Trim(E_CMC5.Hint);
FieldByName('XH').AsString := Trim(E_XH5.Text);
FieldByName('BZLBDM').AsString := Trim(E_BZLB5.Hint);
FieldByName('BZTS').Value := Trim(E_BZTS.Text);
FieldByName('BZRL').AsString := Trim(E_BZRL.Text);
FieldByName('BZ').AsString := Trim(E_NOTE5.Text);
Post;
ShowMsg('保存数据成功!');
except
ShowMsg('保存数据出错!');
end;
if Button12.Hint = '0' then begin //添加
ADOT_YKSDSB.Append;
end;
if Button12.Hint = '1' then //修改
if not ADOT_YKSDSB.Locate('ywbh;xh', VarArrayOf([ywbh, Trim(E_XH5.Text)]),[]) then begin
ShowMsg('请先选择要修改的数据');
exit;end
else ADOT_YKSDSB.Edit;
with ADOT_YKSDSB do
FieldByName('YWBH').AsString := Trim(E_YWBH5.Text);
FieldByName('GDSDM').Value := Trim(E_GDS5.Hint);
FieldByName('CDM').Value := Trim(E_CMC5.Hint);
FieldByName('XH').AsString := Trim(E_XH5.Text);
FieldByName('BZLBDM').AsString := Trim(E_BZLB5.Hint);
FieldByName('BZTS').Value := Trim(E_BZTS.Text);
FieldByName('BZRL').AsString := Trim(E_BZRL.Text);
FieldByName('BZ').AsString := Trim(E_NOTE5.Text);
Post;
ShowMsg('保存数据成功!');
except
ShowMsg('保存数据出错!');
end;
可能是字段与数据不匹配,请仔细检查数据及字段。