Home > database >  PB in the BLOB types cannot be deposited in the database
PB in the BLOB types cannot be deposited in the database

Time:10-06

Using the method is as follows:

The following functions in addition to choose photos function can be realized, the other two have no effect, bother everybody to help see, thank you,

List three fields, ygbm char (10), ygxm char (10), photo varbinary

Code in the photo button to select the following
String ls_pathname, ls_filename
Integer li_value li_FileNum, loops, I
Long ll_fileLength bytes_read, new_pos

Li_value=https://bbs.csdn.net/topics/GetFileOpenName (" choose photo ", & amp;
+ ls_pathname ls_filename, "JPG", "JPG Files (*.jpg), *. JPG")
IF li_value=https://bbs.csdn.net/topics/1 THEN

//Set a wait cursor
SetPointer (HourGlass!
//Get the file length, and open the file
Ll_fileLength=FileLength (ls_filename)//get the length of the file name
Li_FileNum=FileOpen (ls_filename, & amp;
StreamMode! , Read! , LockRead!)
//Determine how many times to call FileRead
IF ll_filelength & gt; THEN 32765
IF the Mod (ll_filelength, 32765)=0 THEN
Loops=ll_filelength/32765
The ELSE
Loops=(ll_filelength/32765) + 1
END the IF
The ELSE
Loops=1
END the IF
//Read the file
New_pos=1
FOR I=1 to loops
Bytes_read=FileRead (li_FileNum, b)
Tot_b=tot_b + b
NEXT
FileClose (li_FileNum)

P_1. Setpicture (tot_b)
Elseif li_value=https://bbs.csdn.net/topics/-1 then
MessageBox (" choose photo ", "open the file error!" )
End the If

Save function following

Dw_1. Accepttext ()
Dw_1. The update ()
commit;
String ls_ygbh
Ls_ygbh=dw_1. Object. Ygbm [dw_1 getrow ()]

UPDATEBLOB ygzl SET photo=: tot_b

WHERE ygbm=: ls_ygbh

USING the sqlca.

IF the sqlca. SQLNRows & lt;> 0 THEN

Messagebox (" prompt ", "no data")

The else
COMMIT the USING the sqlca;
END the IF

Another is written under the data window itemchanged events

Choose a case dwo. Name
Case 'ygbm'
String ls_ygxm, ls_ygbh2

Ls_ygbh2=dw_1. Getitemstring (sa1, "ygbm")
Messagebox (" ", string (ls_ygbh2))
The select ygxm into: ls_ygxm from ygzl where ygbm=: ls_ygbh2;
//messagebox (" ", string (ls_ygxm))
If the sqlca. Sqlcode<> 0 then
Messagebox (" tip ", the sqlca. Sqlerrtext)
Return
The else
Dw_1. Object. Ygxm [row]=ls_ygxm
End the if

Blob Emp_id_pic

SELECTBLOB photo

INTO: Emp_id_pic

The FROM ygzl

WHERE ygbm=: ls_ygbh2

USING the sqlca.

P_1. SetPicture (Emp_id_pic)
The end choose

CodePudding user response:

If dw_1. The update ()=1 then
commit;
The else
//messagebox (" error ",... )
The rollback.
End the if
.
  • Related