procedure Tgb_k.PageControl1Change(Sender: TObject);
begin
if DM.CDS_gb_01.state=dsInsert  then
  begin
  image1.Visible:=false;
  end
else
try
if FileExists(dm.CDS_GB_01.fieldbyname('photo').asstring) then
   image1.Picture.LoadFromFile(dm.CDS_GB_01.fieldbyname('photo').asstring);
except
ShowMessage('sorry,no picture');
end;
end;我点dbgird里面的记录时  如果 photo 有图片目录 就显示图片 没有会显示上条
显示过的图片记录 而不能显不ShowMessage('sorry,no picture');

解决方案 »

  1.   

    try
     if FileExists(dm.CDS_GB_01.fieldbyname('photo').asstring) then
       image1.Picture.LoadFromFile(dm.CDS_GB_01.fieldbyname('photo').asstring)
     else
       ShowMessage('sorry,no picture');except
       ShowMessage('sorry,no picture');
    end;
    end;
      

  2.   

    procedure Tgb_k.PageControl1Change(Sender: TObject);
    begin
    if DM.CDS_gb_01.state=dsInsert  then
      begin
      image1.Visible:=false;
      end
    else
    try
       image1.Picture.LoadFromFile(dm.CDS_GB_01.fieldbyname('photo').asstring);
    except
      ShowMessage('sorry,no picture');
    end;
    end;
      

  3.   

    FileExists 如果文件不存在,返回一个值,不会抛出异常,所以你捕获不到
      

  4.   

    没有就什么都不显示的:http://218.56.11.178:8020/web/index.aspx-》下载基地-》例程-数据库/报表-》数据库图片bmp/jpg存储(Accsee)/数据库存储bmp/jpg图片(sql server)