CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Posts
    29

    How to load picture ???

    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?


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: How to load picture ???

    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.../3/68.asp?FR=0

    Tom Cannaerts
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: How to load picture ???

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Jun 2001
    Posts
    29

    Re: How to load picture ???

    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?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured