Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-10

Loading an image to a mysql blob

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Terry A. Haimann

I tried loading an image into a Medium Blob.  The image uploads and shows up on my form, but when I click post on my DbNavigator the program gives me an access violation.

Here is the source code:

procedure TPropertyForm.ImgButClick(Sender: TObject);
Var
  MyImageFile, MyDir:                              String;
begin
     MyImageFile := '/';
     if OpenDialog1.Execute then
     begin
          MyImageFile := OpenDialog1.Filename;
     end;
     DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile);
End;

Am I missing something I have to do?  The blob should be large enough, they are supposed to be able to hold 16 Meg and the jpegs are running about 2 - 3 meg.  I am running Mint 18.3, using Mysql 5.7.22 and using ZeosDBO.

Terry Haimann

Reply by email

John Landmesser
to Terry A. Haimann
Terry A. Haimann wrote 25 lines
I tried loading an image into a Medium Blob.  The image uploads and shows up on my form, but when I click post on my DbNavigator the program gives me an access violation. Here is the source code: procedure TPropertyForm.ImgButClick(Sender: TObject); Var   MyImageFile, MyDir:                              String; begin      MyImageFile := '/';      if OpenDialog1.Execute then      begin           MyImageFile := OpenDialog1.Filename;      end;      DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile); End; Am I missing something I have to do?  The blob should be large enough, they are supposed to be able to hold 16 Meg and the jpegs are running about 2 - 3 meg.  I am running Mint 18.3, using Mysql 5.7.22 and using ZeosDBO. Terry Haimann

.. perhaps a Dataset.edit before

DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile);
DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile);

Reply by email

Terry A. Haimann
to John Landmesser

I had already tried that.  I clicked on edit from the dbnavigator, uploaded the image and clicked post.  That is when the program would crash.

I have taken the program a different route, gotten rid of the blob and replaced it with a varchar.  The varchar now has the filename of the jpeg.  It's not fast, but it works.

Terry

John Landmesser wrote 38 lines
Am 31.10.18 um 13:05 schrieb Terry A. Haimann via Lazarus: > > I tried loading an image into a Medium Blob.  The image uploads and > shows up on my form, but when I click post on my DbNavigator the > program gives me an access violation. > > Here is the source code: > > procedure TPropertyForm.ImgButClick(Sender: TObject); > Var >    MyImageFile, MyDir:                              String; > begin >       MyImageFile := '/'; >       if OpenDialog1.Execute then >       begin >            MyImageFile := OpenDialog1.Filename; >       end; >       DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile); > > End; > > Am I missing something I have to do?  The blob should be large > enough, > they are supposed to be able to hold 16 Meg and the jpegs are > running > about 2 - 3 meg.  I am running Mint 18.3, using Mysql 5.7.22 and > using > ZeosDBO. > > Terry Haimann .. perhaps a Dataset.edit before DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile); DbPropImg.Picture.Jpeg.LoadFromFile(MyImageFile);

Reply by email