CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    7

    Question Save images in Access Using ADO in VB6

    How To Save Image File as OLE Object in Access OLE Object Field using ADO as database access object in VB6

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Save images in Access Using ADO in VB6

    Welcome to the Forum

    Take a look at our FAQ, you will see couple of threads that will help you solve your problem.

    http://www.codeguru.com/forum/showth...hreadid=197304

  3. #3
    Join Date
    Sep 2006
    Posts
    635

    Re: Save images in Access Using ADO in VB6

    i hope it's useful
    Code:
    sub SaveImg(Path a string)
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim mystream As New ADODB.Stream
    Set mystream = New ADODB.Stream
    
    mystream.Type = adTypeBinary
    rs.CursorLocation = adUseClient
    
    rs.ActiveConnection = ConnectionString
    
    rs.Open "SELECT id_TABLE,info,image FROM imagenes where ID_TABLA=condition" 'condition must be value that return 0 recordsets
    rs.AddNew
    mystream.Open
    mystream.LoadFromFile path
    
    rs.fields("id_table")=your_ID
    rs.Fields("image") = mystream.Read
    rs.Fields("info") = "bmp"
    rs.Update
    
    rs.Close
    mystream.Close
    
    
    end sub
    and ID_TABLA is primary of table
    Last edited by hensa22; October 16th, 2006 at 08:15 AM.

  4. #4
    Join Date
    Oct 2006
    Posts
    7

    Re: Save images in Access Using ADO in VB6

    I am handling a large-scale project entitled as MIS (Marketing information System). I am using Vb 6 as front end, Ms Access as back end and Crystal report 8 as reporting tool.

    1) In the project i am required to save customers image to database, and it should be shown in individual customer’s report, which will include that image. I had taken OLE field in the database to save images. I had taken Common dialog box control to select image and display it in OLE control, but i don't know how to save the OLE controls image to database. i am using ADO object to access the database. How could I can save and retrieve the image from database? Is it possible to save images by using other controls like Picture box or image control in the form? I want to save image as bitmap in the database.

    2) The size of project is very large then it is useful to store image to database? Will it make it slower to access database?

    3) Saving path of image in database will make any difference? If i do so then how can show the images in report (Crystal report 8)?

  5. #5
    Join Date
    Feb 2005
    Location
    Kolkata, India
    Posts
    430

    Re: Save images in Access Using ADO in VB6

    When working images in Database, the type of project you are working on, use small pictures. Because the whole database will be loaded with data and loading big image data will make it very big and you will face problems. Try to store images as small as possible. This will also make you loading and saving time short as byte by byte will be stored into the database and will be retreaved.

    The access time of a record depends on the size, struncture of a database and also the processor speed, if you have a pentium III amd have a huge database it is obvious that it will take time to load and save data.

    Saving path of images are good practice but it have many disadvantage. Once the folder you store the image get moved you are unable to load the images. Moreover you cannot protect a particular image from loading as it is open. If any one renamed an image but you have a different name in the database you cannot retrieve the same.

    Hope i have been able to give your some information.

    regards
    Amarjit
    Try, Try Hard, Try Harder one day you will Succeed.

  6. #6
    Join Date
    Oct 2006
    Posts
    7

    Re: Save images in Access Using ADO in VB6

    Thanx amarjitamar,
    Your suggestions will help me out! Thx once again

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