473,379 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,379 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 23037

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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.