Home > database >  The database images
The database images

Time:09-24

Pb added to the database in the photo, it is like to add other data directly, or have to write code to add in the application? Each ace

CodePudding user response:

Will read in a blob of images, and then save the blob data, and other data preservation

CodePudding user response:

Use the function reads the image file to the blob variable (assuming the lb)
http://blog.csdn.net/yyoinge/article/details/6935768

Then use updateblob syntax to submit to the database
Updateblob t_ table name set picture fields=: lb where a=: a value using the sqlca.

CodePudding user response:

refer to the second floor yyoinge response:
using the function reads the image file to the blob variable (assuming the lb)
http://blog.csdn.net/yyoinge/article/details/6935768

Then use updateblob syntax to submit to the database
Updateblob t_ table name set picture fields=: lb where a=: a value using the sqlca.


Is this kind of treatment,

CodePudding user response:

Put the following code is saved as a text file with notepad
And change the file name to gf_read_graphfile SRF
Imported into the pb in

 
Global type gf_read_graphfile from function_object
End type

Forward as
Global function blob gf_read_graphfile (string as_filename)
End as

Global function blob gf_read_graphfile (string as_filename); Blob lbb_read, lbb_total
Integer li_fileptr li_loops, I
Long ll_filelen, ll_bytes_read
Ll_filelen=FileLength (as_filename)//get the length of the file, must be open before
Li_fileptr=FileOpen (as_filename STREAMMODE! , Read! , LOCKREAD!)
IF li_fileptr=1 THEN
MessageBox (' hint! ', "graphics file open error!" )
RETURN lbb_total
END the IF
IF ll_filelen & gt; THEN/32765/a read only 32 k
IF the Mod (ll_filelen, 32765)=0 THEN
Li_loops=ll_filelen/32765
The ELSE
Li_loops=(ll_filelen/32765) + 1
END the IF
The ELSE
Li_loops=1
END the IF
//loop reads the images file
FOR I=1 TO li_loops
Ll_bytes_read=FileRead (li_fileptr lbb_read)
Ll_filelen=Len (lbb_read)
Lbb_total=lbb_total + lbb_read
NEXT
FileClose (li_fileptr)
RETURN lbb_total

End the function


Use this function to

 

Bolb lblb_graph
String ls_graphfile

The sqlca. The AutoCommit=TRUE

Ls_graphfile="C: \ text. BMP"
Lblb_graph=gf_read_graphfile (ls_graphfile)

The update table name set the field name=: lblb_graph where conditions;
IF the sqlca. Sqlcode=0 THEN
COMMIT;
The ELSE
The ROLLBACK.
END the IF



The field type must be what type of support bolb field
Such as SQL server image field type

CodePudding user response:

This function is used to convert bolb values in the database to the image file
Put the following code is saved as a text file with notepad
And change the file name to gf_blobtofile SRF
Imported into the pb in

 
Global type gf_blobtofile from function_object
End type

Forward as
Global subroutine gf_blobtofile (blob pb_blob, string ps_file)
End as

Global subroutine gf_blobtofile (blob pb_blob, string ps_file);//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//parameters:
//value blob pb_blob database blob of picture
//value string ps_file picture path such as c: \ test. BMP
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//return: (none)
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//author: WLshi
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Copyright (c) 2002-2006 DATAWINDOW (TM), All rights reserved.
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//modify history:
//
//====================================================================

Blob zpbuff
UInt sub, n, j, fh1
String ext, file2
Long ll, bytes_read new_pos, Len

File2=ps_file
FileDelete (file2)
Fh1=FileOpen (file2, StreamMode! The Write! , SHARED! , Append!)
Ll=Len (pb_blob)
N=0
IF ll & gt; THEN 32766
IF the Mod (ll, 32766)=0 THEN
N=ll/32766
The ELSE
N=(ll/32766) + 1
END the IF
The ELSE
N=1
END the IF

New_pos=1
FOR j=1 TO n
Zpbuff=BlobMid pb_blob new_pos, (32765)
Bytes_read=FileWrite (fh1 zpbuff)
New_pos=new_pos + 32765
NEXT
FileClose (fh1)



End subroutine



The use of the function

 
Bolb lblb_graph
String ls_graphfile
Ls_graphfile="c: \ aaa. BMP"

Selectblob field name into: lblb_graph the from name of the table where conditions;
Gf_blobtofile (lblb_graph ls_graphfile)




So can the

The hope can help LZ

CodePudding user response:

Thank you, I'll try

CodePudding user response:

O store photos of the steps in the pb, urgent need, thank you
  • Related