| |

VerySource

 Forgot password?
 Register
Search
View: 2553|Reply: 14

Why can't I add photos all the time?

[Copy link]

4

Threads

15

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-12-9 11:00:01
| Show all posts |Read mode
The following code is to add photos to the corresponding fields in the database, but what's the matter, it always fails to increase?
There is no error when running, but open the database to see the corresponding field, and there is nothing? Is blank,
what is going on?



//The premise is that query4 has been opened!

if image1.Picture.Graphic = nil then
  begin
    if messageDlg('The photo has not been modified, do you want to update the photo, press Yes, otherwise No!', mtConfirmation, [mbYes, mbNo], 0,) = mrYes then
    begin
      if OpenPictureDialog1.Execute then
      try
        JpgPic:=TJpegImage.Create;
        tempStream:=TMemoryStream.Create;
        tempStream.Clear;
        JpgPic.LoadFromFile(OpenPictureDialog1.FileName);
        Image1.Picture.bitmap.assign(JpgPic);
        JpgPic.SaveToStream(tempStream);
        query4.Edit;
        TBlobField(query4.FieldByName('s_picture')).LoadFromStream(tempStream);
      finally
        JpgPic.Free;
        tempStream.Free;
      end;
    end;
  end;
Reply

Use magic Report

4

Threads

15

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-12-9 13:45:01
| Show all posts
Why can't I add photos all the time?
why? ? ?
Who knows what to say? Thank you?
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-12-9 14:00:01
| Show all posts
It seems that you haven't submitted it? (I don't know if you haven't published the code completely?)
Reply

Use magic Report

4

Threads

15

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-12-9 14:15:01
| Show all posts
It's basically the code above! !
What do you say about submitting?
query4.post?
It is wrong to add this line! ! !
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-9 14:30:01
| Show all posts
Try changing to bmp. Delphi's native control does not support jpeg.
Reply

Use magic Report

1

Threads

13

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-12-9 14:45:01
| Show all posts
...........
tmpStream.Seek(0,0); <-- Do you want to reset the Stream?
TBlobField(query4.FieldByName('s_picture')).LoadFromStream(tempStream);
...
Reply

Use magic Report

0

Threads

53

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-12-9 15:00:01
| Show all posts
I have encountered this problem, jpg can not be saved into the SQL SERVER database
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-9 15:15:01
| Show all posts
UADOTbl.Edit;
GrapField:=TBlobField(UADOTbl.FieldByName('DataImg0'));
GrapField.LoadFromStream(TmpStream);
UADOTbl.Post;

Is this change the following
Reply

Use magic Report

4

Threads

15

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-12-9 15:30:01
| Show all posts
Is an Access database
Reply

Use magic Report

4

Threads

15

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-12-9 15:45:01
| Show all posts
Still not resolved! ! !
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list