CodePudding user response:
LZ didn't clear the question, what is "can't update the client"What is the OLE
This tip should be a messagebox you say so in your application is difficult for us to help you
CodePudding user response:
Is introduced by an example, according to the image directly in the database and its printing method, environment for PB and ORACLE database instance,(1) set up two tables:
The worker information table emp_info
The length of the column type content
Emp_ID Number # 4 worker
The Name Char 8 Name
1 Sex Sex Char
.
Table 1
Worker photos emp_photo table
The length of the column type content
Emp_ID Number # 4 worker
Photo Long raw Photo
Table 2
Both with emp_ID keyword, type long raw data can be used to store photos,
Connect to the database in the application system of the main program, define a global variable integer g_emp_ID, said to deal with photos of the worker, a new window w_photo, window instance variables:
Blob I_photo//store photos data
Int fp//file pointer
(3) image storage
Will be scanned and converted to JPG format file worker photos stored in a directory, and deposited in the worker now addresses how the photograph in the emp_photo table:
Create a button in the window cb_store, click event programming is as follows:
String ls_path_filename, ls_filename
Getfileopenname (' select photo Files' ls_path_filename ls_filename, "JPG", "JPG Files (*.jpg), *. JPG")
If ls_filename="' then return
Fp=fileopen (ls_path_name streammode!)//open JPG image file
Fileread (fp, i_photo)/photo/data into a blob type i_photo variable
Fileclose (fp)//photo JPG file capacity is very small, only read up to 64 KB of data
Data stored in the worker//photograph table
Updateblob emp_photo set photo=: i_photo where emp_ID=: g_emp_ID;
If the sqlca. Sqlcode=1 then
The ROLLBACK.
Messagebox (' error message ', 'photo storage failure! ')
The else
commit;
End the if
(4) image shows
Worker photo requirements and worker information display, print, in the window to establish a data window control dw_1, then USES the data window brush with freeform dw_emp_info style to create a new data window, it to the worker number as a parameter retrieval emp_info information table (worker) of data: the worker number and the name, display and print for handling pictures, establish an OLE object in the data window, in the event of "inert object" (insert objects) dialog box, select "insert control" radio button, the "control type" controls to select find "Microsoft Web browser" list box, select it, and then press ok button, input ole_photo in the object name attribute, and then press ok, then add a rectangle in the data window object, it is to show pictures of objects, adjust the size of the object, that can accommodate the actual image size, as shown in figure 1:
Figure 1
Set dw_1 Datawindow Object Name attribute for dw_emp_info, writing in the window open event the following procedures:
Dw_1. Settransobject (sqlca)
Dw_1. Retrieve (g_emp_ID)
Create a button in the window cb_display, realize the image display, click event program is as follows:
//from pictures table to retrieve data
Selectblob photo into: i_photo from emp_photo
Where emp_ID=: g_emp_ID;
//set up temporary files
Fp=fileopen (' c: \ ~ ~ temp_photo. JPG, streammode! The write! , lockreadwrite! The replace!
If fp=1 then
Messagebox (' error message ', 'JPG temporary files to establish failure)
Return
End the if
//build JPG image file
Filewrite (fp, i_photo)
Fileclose (fp)
//in data window display photos
Dw_1. Object. Ole_photo. Object. Navigate (' c: \ ~ ~ temp_photo. JPG)
5] image printing
Create a button cb_print in the window, click event is as follows:
Dw_1. Print ()
Using data window print function of the worker information can be printed with photos,
4. Conclusion
From the above example shows, the method using the file function processing JPG photo files and BLOB data conversion between memory variables, with a BLOB variable to the database storage or read image data, by Microsoft Web browsing control implementation JPG file of the display and print, as shown in figure 2,
Figure 2
The method is fast and efficient, has realized the JPG image file of the database storage, display, print, image database retrieval significantly faster than the speed of the file system; In network operation application system greatly reduce the network load, improve the speed, Also greatly saves database storage capacity, as shown in figure 2 processing method also applies to the use of support the development of WEB browsing control tools and support long binary data storage of database application system,
CodePudding user response:
According to your description, your code is read and write image information to the database, to modify the pictures it doesn't matter,CodePudding user response:
https://img.codepudding.com/202009/100697241215471.gifCodePudding user response:
https://img.codepudding.com/202009/100697241215471.gifCodePudding user response:
sweat, learn a recruit, hair is bad