472,354 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 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 5084
180 100+

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
  6. Private Const ChunkSize As Integer = 16384
  7. Private Const conChunkSize = 100
  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
  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
  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
manpreet singh dhillon hoshiarpur
Oct 31 '07 #2
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

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...
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...
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...
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...
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...
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)...
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...
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...
by: noecantim | last post by:
Hi, Ive 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...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

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.