473,387 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to connect access picture(OLE) with vb6

i m doing Student Info program in VB6 using Access2000 for database
i have connected the file using ADO and Microsoft jet oledb 4.0
the data is connected with vb form but i have sotred student picture(Ole object) in Access file. the picture is not diplaying in vb form. Pls help me for the code.
Oct 30 '07 #1
2 5247
9815402440
180 100+
hi

the easy way is to save the picture path in access in a text field. when you want to display the image then use loadPicture(<File path>)

i found following code from somewhere on the web (perhaps theScripts.com)
Expand|Select|Wrap|Line Numbers
  1. Dim CN As New ADODB.Connection
  2. Dim RS As ADODB.Recordset
  3. Dim DataFile As Integer, Fl As Long, Chunks As Integer
  4. Dim Fragment As Integer, Chunk() As Byte, i As Integer, FileName As String
  5.  
  6. Private Const ChunkSize As Integer = 16384
  7. Private Const conChunkSize = 100
  8.  
  9. Private Sub Form_Load()
  10.     CN.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Pubs;Data Source=Test"
  11.     Dim strsql As String
  12.  
  13.     strsql = "SELECT * FROM pub_info where pub_id = '9999'"
  14.     RS.Open strsql, CN, adOpenForwardOnly, adLockReadOnly
  15.       ShowPic
  16.     Set RS = Nothing
  17.     Set RS = New Recordset
  18. End Sub
  19.  
  20. Private Sub ShowPic()
  21.     DataFile = 1
  22.     Open "pictemp" For Binary Access Write As DataFile
  23.         Fl = RS!logo.ActualSize ' Length of data in file
  24.         If Fl = 0 Then Close DataFile: Exit Sub
  25.         Chunks = Fl \ ChunkSize
  26.         Fragment = Fl Mod ChunkSize
  27.         ReDim Chunk(Fragment)
  28.         Chunk() = RS!logo.GetChunk(Fragment)
  29.         Put DataFile, , Chunk()
  30.         For i = 1 To Chunks
  31.             ReDim Buffer(ChunkSize)
  32.             Chunk() = RS!logo.GetChunk(ChunkSize)
  33.             Put DataFile, , Chunk()
  34.         Next i
  35.     Close DataFile
  36.     FileName = "pictemp"
  37.     Picture1.Picture = LoadPicture(FileName)
  38. End Sub
regards
manpreet singh dhillon hoshiarpur
Oct 31 '07 #2
debasisdas
8,127 Expert 4TB
Please find the details of storing of images and retrival of images in the articles section of VB.
Oct 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
0
by: Otis Hunter | last post by:
I have been fighting with this for days and your expert help is needed! Below is the code I am executing which results with "Object doesn't support this property or method". The error is occuring...
13
by: Krzysztof Bartosiewicz | last post by:
Hi! I have a problem with an access database. The database which I designed and made using MS access works perfectly OK on my computer however it is not working at all on computers for which it...
1
by: Marco Castro | last post by:
Along time ago I created an access database where I used the ole field type to store images. If I look at the table data it has the work Picture in its field. The image in that field displays...
2
by: Stan Smith | last post by:
I couldn't decide which newsgroup to post this in so I thought I would start here. I can create an "OLE Object" field manually in Microsoft Access and insert an Excel spreadsheet or a Word...
0
by: Skiran | last post by:
Hi to everybody, I am handling a large-scale project of 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)...
0
by: Bauhaus | last post by:
I have a table with an OLE field that contains a picture. Unfortunately, when I make a form, the picture isnt visible on it, I only see a description and must double click the pic to open it (an...
2
by: Stubbs54 | last post by:
Hi, I'm currently creating a database to manage a large filing system (so about 2,500 pdf documents). I was going to link the documents in as OLE objects; however, the 2 GB limit in Access has...
3
by: noecantim | last post by:
Hi, I´ve created a DTS with Visual Studio .Net (SSIS) for transfer data from a SQL Server database to an Access Database. It is not necessary to know SSIS to you be able to help me since I can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.