Home > database >  PB9.0 to save images in the database
PB9.0 to save images in the database

Time:09-30



1, I want to double click on the picture box pops up a picture of tool form how to write code?
2, the images as shown in picture box how to deposited in the database?
Out how pictures of the 3, deposited in the database is shown in the picture box?
4, want to ask next pull data window how to do?
Too many problems in it please, eldest brother thank you!!!!!!

CodePudding user response:

1. Use getfileopenname () function
2. Use the insert statement
3. The blob bl
Selectblob PIC into: bl from table;
P_1. Setpicture (bl)
4. Select a list, Edit properties page style of type into dropDownDW
Choose the data from the drop-down below datawindow window
Display column in the select the columns to display content
Select the content of the stored data column

CodePudding user response:

Access the binary large object

In the process of database application development, often to some note information stored in the database, and these remarks information content generally larger, diverse formats and may be images, audio files, video files, etc., can be used in the PB OLE method, also can be directly treated with script,
In this paper, with a script to handle database is ASA8, attachment is the table design, the article omitted,
1, set up a working space (workspace), named: blob,
2, the establishment of an application (application), named: blob,
3, design a table blobtest, the fields are defined as follows:
The Column Name Data Type Width Null Comment
No Integer No number
The Name Varchar 10 No Name
Photo Photo Long Binary Null

4, establish a window w_input, built-in controls as follows:
Control name type description
Sle_no SingleLineEdit input number
Sle_name SingleLineEdit input name
Cb_select_photo Command Button to choose photos file
Sle_photo SingleLineEdit display picture filename
Cb_save Command Button to save record (this article only insert)
Query cb_query Command Button
Cb_exit Command Button to exit the
P_1 Picture display Picture
Interface is as follows:


5, write a script
1), cb_select_photo clicked event:
String ls_photofile
String ls_named
The integer li_value

//select photo files
Li_value=https://bbs.csdn.net/topics/GetFileOpenName (" select image files ", & amp;
+ ls_photofile, ls_named, "image", & amp;
+ "BMP Files (*. BMP), *. BMP," & amp;
+ "JPG Files (*.jpg), *. JPG")
Sle_photo. Text=ls_photofile
P_1. Picturename=ls_photofile

2), cb_save clicked event: (this article only deals with the new record, interested friends can improve his)
Long ll_no
String ls_name
String ls_photofile
The integer li_filenum
The integer li_loops
The integer li_counter
Long ll_filelen
Blob lb_read
Blob lb_picture
If sle_no. Text='or sle_name. Text=' or sle_photo. Text="' then return
Ll_no=long (sle_no. Text)//no
Ls_name=sle_name. Text//name
Ls_photofile=sle_photo. Text//photo files
//insert records, write no, the name field
Insert into blobtest (no name)
Values (ll_no, : ls_name);
If the sqlca. Sqlcode=1 then
The Rollback.
Messagebox (' insert record error, the Sqlca Sqlerrtext)
Return
The Else
Commit;
End the if
//get a big small
wenLl_filelen=FileLength (ls_photofile)

//open the file
Li_filenum=FileOpen (ls_photofile STREAMMODE! , READ! , LOCKREAD!)
/* FileRead () function may be not by reading large text in 32 k,
Computing will make use FileRead letter, and count the number of times */
IF ll_filelen & gt; THEN 32765
Li_loops=((ll_filelen - 1)/32765) + 1
The ELSE
Li_loops=1
END the IF
//read the file
FOR li_counter=1 to li_loops
FileRead (li_filenum lb_read)
Lb_picture=lb_picture + lb_read
NEXT
FileClose (li_filenum)
//display picture
P_1. SetPicture (lb_picture)
//write database
UPDATEBLOB blobtest
The SET photo=: lb_picture
WHERE no=: ll_no;
IF the Sqlca. SQLNRows & gt; 0 THEN
COMMIT;
Messagebox (' message 'and' record keeping success! ')
The Else
The Rollback.
Messagebox (' message 'and' record keeping is successful, picture file save failed! '+ sqlca. Sqlerrtext)
END the IF

3), cb_exit clicked event:
Close (the parent)

4), cb_query clicked event:
Blob lb_picture
Long ll_No
If sle_no. Text="' then return
Ll_no=long (sle_no. Text)//no
SelectBlob photo
Into: lb_picture
The From blobtest
Where no=: ll_no;
//display picture
P_1. SetPicture (lb_picture)

6, rendering
1), insert: as shown in figure input and select the image, and then select the save button,

2), enter the several number and name and select the image, and then one by one, according to the following (this paper photos taken from MY83 BBS, if there is any infringement, please inform us) :
Jiangnan niche:

Shenzhen native:

If Xia Zhi:

Base guest unknown:

Beijing toilet:


CodePudding user response:

Picture had better use the db ole object is entering the dw
Where the computed columns, there is a db ole object
Chosen and corresponding relationship, before you say three functions don't have to write code
As dw_1, update, retrieve operating together
Drop-down data window is a window, you put his style as DDDW, choose good display column data column

CodePudding user response:

This is a picture I have written a deposit and display the script, for reference,
Including gs_ beginning for the global parameters, no statement here, but you can see,

Dw_1. Setfocus ()
IF DW_1. GETROW ()=0 THEN
MESSAGEBOX (" prompt ", "currently there is no record, are not allowed to select pictures!" )
RETURN
END the IF

If FileExists (BMP/picture. JPG ")=false or FileExists (BMP/notpict. JPG ")=false then
Messagebox (" prompt ", "I'm sorry, can't find the system default pictures, can't operate!" )
Return
End the if

String the pathname, named ls_image, ls_curdir
An integer value
Long li_ph

String is_lnifile
Is_lnifile=uf_getapp () + "\ RSGL ini"
The default path ls_curdir=profilestring (is_lnifile, "photos", "path", ")
//the default path to photo:
If ls_curdir & lt;> "' then
SetCurrentDirectoryA (ls_curdir)
End the if

Li_ph=dw_1. Getitemnumber (dw_1 getrow (), "rsgl_ph")

(value=https://bbs.csdn.net/topics/GetFileopenName "(add images) selected image files", & amp;
+ the pathname, named, "picture", & amp;
+ "JPG Files (*.jpg), *. JPG")

Ls_curdir=mid (pathname, 1, pos (pathname, named) - 1)

If ls_curdir & lt;> "' then
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related