如题

解决方案 »

  1.   


    procedure TForm3.btn1Click(Sender: TObject);
    var
      JPG : TJPEGImage;
      S : TBlobStream;
    begin
      if not dlgOpenPic.Execute then exit;
         if not (MyQry1.state in [dsEdit, dsInsert]) then
       MyQry1.Edit;
       S := TBlobStream.Create(TBlobField(MyQry1.FieldByName('gongwy_photo_file')),bmWrite);
      try
        img1.Picture.LoadFromFile(dlgOpenPic.FileName);
        img1.Picture.Graphic.SaveToStream(S);
      finally
        S.Free;
      end;
      MyQry1.Post;  //这里提示错误,一堆乱码
    end;错误提示:First chance exception at $7C812AEB. Exception class EMyError with message '
    #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S蝳绯?D\\茄LA&蚖彎????獃糣S榕mX藟 U愊 諹x詶#u裭to9tHs湒楈X黩囦?g纽' at line 3'. Process TestPIC.exe (680)
      

  2.   

    这个问题摆好久了。
    我查找到了一个办法,将图片用流的read方式和inttohex转成十六进制再写入MySQL,不知是否可行
      

  3.   

    提示说你的SQL语法不正确。那不会是你在SQL中字段类型不正确。
    我在MS SQL中能正确保存。