delphi 出错Incompatible types: 'String' and 'Integer'
procedure TForm6.btn1Click(Sender: TObject);
var
S1:string;
begin
with unit1.CreationForm.qry2 do
begin
Close;
sql.Clear;
SQL.Add('select * from Template where partnum='''+edt1.text+'''');
Open;
unit1.CreationForm.lbl3.Caption:=fieldbyname('partname').asstring;
unit1.CreationForm.lbl9.Caption:=fieldbyname('partnum').asstring;
unit1.CreationForm.pnl5.Caption:=fieldbyname('CodR').asstring;
S1:=fieldbyname('NSJECT1').asstring;
end;
if unit1.CreationForm.qry2.RecordCount<>1 OR s1='' then
begin
MessageBox(handle,'无此件号或未填写项目!','Error',MB_ICONHAND);
Exit;
end
else
unit1.CreationForm.dbgrdh1.Enabled:=false;
MessageBox(handle,'导入成功!','提示',MB_OK+MB_ICONASTERISK);
end;
上面的 if unit1.CreationForm.qry2.RecordCount<>1 OR s1='' then 这里错误!
修改帆袭简一下
if (unit1.CreationForm.qry2.RecordCount<>1) OR (s1='') then
加括号改变优先态裤级顺序,没加的禅茄话,会先执行 1 or s 这样就会出现那个不匹配的错讯