472,783 Members | 961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 472,783 developers and data experts.

BLOB - Retrieve image stored in database

sashi
1,754 Expert 1GB
BLOB - Retieve image stored in database

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
  39.  
Dec 4 '06 #1
0 22817

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

Similar topics

2
by: ATK | last post by:
Hi, I have a image stored in a blob column in my db... i know how to retrieve it correctly and yes, i need to save it in a blob in the db. How can i get the width & height from that image? I...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
0
by: Big George | last post by:
Hello, I'm trying to save a jpg file of 300KB as a BLOB field in an Oracle 10g Database. If I try to call a Stored Procedure, it fails. If I use CommandText with SQL sentence, it success. I...
3
by: alexseow | last post by:
<img src="image.asp?id=1"> --------------------------------------------------------------- <%Option Explicit%> <!-- #include file="IMS/includes/dbconn.asp"--> <% dim MyConn,SQL Set MyConn...
1
by: sana krishna | last post by:
Pls Help me-------------- I use ASP(C#.NET) and oracle. When i retrive image from database .it display error message... System.InvalidCastException: Unable to cast object of type 'System.DBNull'...
7
pradeepjain
by: pradeepjain | last post by:
hii, i have stored the images from form to database in blob format.now i have a necessity to retrieve image from database and store it in a folder ..how to do this.. thanks, ...
3
by: brijesh1234 | last post by:
dear Sir/madam I am getting a problem while displaying a image from database Database : MSSQL2000 I have a table named “Image” having following fields as ImageId int Image Image
6
by: vjayis | last post by:
hi i have stored user profile images in an BLOB field., and need to display it as an thumbnail image in their profile page., and i searched through the net and got the result using header...
4
selvasoft
by: selvasoft | last post by:
Hi Please help me i want display all images from my database. but here my code that will display only one image from database. But i want all images, any one help me. <html> <head>...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.