Home > database >  P_1. Setpicture () display picture
P_1. Setpicture () display picture

Time:09-28

I am using pb 9.0 + sql2000.
The code is as follows:


//filedisk
//fileread
String filepath, filename
String ll_path
Int I, f_num, loops, j
Long f_long sum_read, p_new
Blob tot_b, b, PIC
P_new=0
I=getfileopenname (' please select images' filepath, filename, "all Files (*.jpg), *. BMP, *. JPG");
Sle_path. Text=filepath

F_long=filelength (trim (sle_path. Text))

F_num=fileopen (trim (sle_path. Text), STREAMMODE! , READ! , LOCKREAD!)


//on the basis of each read 32 k, decided to read a few times
If f_long & gt; Then 32765
If the mod (f_long, 32765)=0 then
Loops=f_long/32765
The else
Loops=f_long/32765 + 1
End the if
The else
Loops=1
End the if
//loop read
For I=1 to loops
Sum_read=fileread (f_num, b)
Tot_b=tot_b + b
P_new=p_new + sum_read
Fileseek (f_num, p_new, FROMBEGINNING!
Next
Fileclose (f_num)

P_1. Visible=true
SetPicture (p_1, tot_b)


The sqlca. The autocommit=true

Select count (*) into: j from s_orgcode_pic
Where orgcode=: ll_depot;

If j=0 or isnull (j) then

Insert into s_orgcode_pic (orgcode, PIC, createtime)
Values (: ll_depot, : tot_b, getdate ());
End the if
If the sqlca. Sqlcode<> 0 then
Messagebox (" prompt ", "generate data failure" + SQLCA. SQLErrText)
Return 1
End the if


Updateblob s_orgcode_pic set PIC=: tot_b
Where orgcode=: : ll_depot;

The sqlca. The autocommit=false
Selectblob PIC into: PIC
The from s_orgcode_pic where orgcode=: ll_depot;


//p_1. SetPicture (PIC)


The create table database table s_orgcode_pic
(orgcode varchar (12),
PIC image null,
Createtime datetime)


Performed, there are data in the database, is unable to display picture after using selectblob.
I put the SetPicture (p_1, tot_b) on the database storage before the execution is able to display. Not into selectblob?
Have to help me have a look?










CodePudding user response:

Blob write to write the first line of data, built the table type (image) allows a blob field is empty, and then in updateblob (the autocommit=true). Not directly insert,
  • Related