Click to See Complete Forum and Search --> : How to load picture ???
qiaojun
July 9th, 2001, 03:03 AM
i develop a database usign access 97, one table is product information. Inside it, one of the fields is photo. Since i'm using VB developed program to acess the database, how do load the photo and save the photo directly into and from the database without actally entering the database via Microsoft Acess 97?
Cakkie
July 9th, 2001, 04:42 AM
You can use the GetChunk (to retrieve) and the AppendChunk (to add) methods to complete this tasks.
You can check out this article on MSDN that discusses those methods.
http://support.microsoft.com/support/kb/articles/q180/3/68.asp?FR=0
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Iouri
July 9th, 2001, 06:53 AM
Const MAX_PATH = 255
private Const CHUNK_SIZE = 1000
private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (byval nBufferLength as Long, _byval lpBuffer as string) as Long
public Function SavePictureToDB(PictControl as Object, _
RS as Object, FieldName as string) as Boolean
'PURPOSE: SAVES PICTURE IN IMAGEBOX, PICTUREBOX, OR SIMILAR
'CONTROL to RECORDSET RS IN FIELD NAME FIELDNAME
'FIELD TYPE MUST BE binary (OLE OBJECT IN ACCESS)
'SAMPLE USAGE
'Dim sConn as string
'Dim oConn as new ADODB.Connection
'Dim oRs as new ADODB.Recordset''
'sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.MDB;Persist Security Info=false"'
'oConn.Open sConn
'oRs.Open "SELECT * FROM MYTABLE", oConn, adOpenKeyset, _
adLockOptimistic
'oRs.AddNew
'SavePictureToDB Picture1, oRs, "MYFIELD"
'oRs.Update
'oRs.Close
Iouri Boutchkine
iouri@hotsheet.com
qiaojun
July 9th, 2001, 10:04 PM
thanks for your guidance. based on your coding, can i directly implement the code into my program? Or is there any changes needed to make so that the photo can be manipulated (photo loading is my primary concern followed by photo saving) from the database? In my program, i use Ado data control as the interface between my program and the Access 97 database. OK, let's say.
A table named Product contains Product ID (data type is autonumber), Product name (d.t. is string), and Photo (d.t. is OLE object). And the Vb program contains all these field is linked with database via AdodcProduct (ADO data control). Two textboxes are associated with the first two data fields and the image box is associated with photo. How's the coding look like?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.