473,395 Members | 1,504 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,395 developers and data experts.

The BLOB (not the movie!)

ADezii
8,834 Expert 8TB
Of all the questions asked here at TheScripts, the one which appears with the most frequency relates to the storing of Graphic Images within Access. There are basically three techniques available to manipulate Image Files in Access and they are:


  1. Store the Image in an OLE Object Field and display it in a Bound Object Frame. The Image can either be Linked or Embedded.
  2. Store the Path to the Image in a Text Field and use an Image Control to dynamically display it.
  3. Store the Image as a Binary Large Object (BLOB) in an OLE Field, extract the Image when required, and use an Image Control to display the Image.
The first technique is the most problematic primarily because of Server Errors (the Application launched to display the Image) and horrendous Database bloat because of the manner in which Access internally stores Images.

The second approach, although relatively easy to implement, has its own set of inherent problems. This technique cannot be used with Continuous Forms, and a fully qualified UNC Path is a strict requirement. If you move the Images, if they reside on a Server and the Folder containing them is not shared, if the Server is turned off, if you do not have Read Permissions to the PC, I think you get the idea.

After all is said and done, the third technique quickly becomes the obvious choice for Image storage. Storing Pictures as BLOBs in the Database is the most efficient way on containing Image data because the Picture data is stored byte for byte, exact size, with the Images reflecting their true sizes.

When BLOBs are stored in the Database with other data, BLOB and tabular data are backed up and recovered together and are synchronized, there are no File Paths to contend with, and no resultant Database bloating. Data consistency is ensured because INSERT, UPDATE, and DELETE operations occur in the same transaction. Separate security measures need not be created since BLOB and regular data coexist.

The minimal requirement to implement the BLOB technique is two Functions, one to put files into the Database, and the other to take them out. You can use either DAO or ADO to grab the Image File and read it into an OLE Field (1st Function). To display the Image we have to extract it from the Database (2nd Function) into a Temporary File then use an Image Control to display it by setting the Control's Picture property to the Path of the Temp File.

Some of the subject matter that appears in this Tip, as well as code that exists in the Demonstration Database were taken from Alan Warren's web site. I thought that he provided an excellent insight into this Topic and his code provided a very good example of how to implement this functionality. I have changed the entire Theme of the Database, made structural changes to the Tables, cosmetic changes to the Form, and have also added, deleted, and modified Mr. Warren's code. The critical code sections were essentially kept in tact.


Required References:
Microsoft Scripting Runtime
Microsoft ActiveX Data Objects X.X Library
Jan 4 '08
55 24633
This post is really helpful but it was unable to solve my problem

I have disscussed it to community but still waiting for the solution

Thank you all for this great ideas and also thanks to A Dezzi who is still trying to solve my problem
Mar 8 '08 #51
FishVal
2,653 Expert 2GB
Hi, noviceadmin.

As I've posted before, I make a guess VB Picture control Picture property operates with stdole.IPictureDisp (or stdole.StdPicture which is the same). If so you may use stdole library finction SavePicture() to store it as temporary disk file and upload to BLOB field in the manner described above.

At least with MSForms.Image control this works flawless.

Regards,
Fish

P.S. Sure stdole library (...\WINDOWS\system32\stdole2.tlb) has to be referenced.
Mar 8 '08 #52
ADezii
8,834 Expert 8TB
This post is really helpful but it was unable to solve my problem

I have disscussed it to community but still waiting for the solution

Thank you all for this great ideas and also thanks to A Dezzi who is still trying to solve my problem
I'll now Post the PM which I sent to both you and Killer previously and, as you can plainly see, is in a direct line with what FishVal has suggested. The initiative is now yours to test this logic. Should I get a chance, I'll test it also, but with my workload it is not likely.

Thanks for your insight into this matter, Killer. The VB/Access Interface is not the difficult part, it is the saving of the Image within the Picture Box to an Access Database directly as a BLOB. I think I'll recommend your approach, and even test it out myself if and when I get the chance, since my field was originally VB. My logic would be to Save the Image in the Picture Box to a File using the SavePicture Statement, then use the tested BLOB code to do the rest. The only problem my be as to whether this can be handled in a single as opposed to multiple steps. There may also be a problem with the available Graphics Formats supported by a Picture Box. I know that if an Image was loaded as a *.bmp, *.ico, or *.wmf, it will be saved in the same format whereas *.gifs and *.jpgs are always saved in *.bmp format which now involves determining the Graphic Type that was initially loaded into the Control. This problem now becomes more complex by the minute. In any event, forgive me for ranting and thanks again for your help, it is greatly appreciated.
Mar 8 '08 #53
Dear A dezzi

Just wanted to share my success with you and all who helped me totake the steps .
finall i decide to store the Image path to database and my software is working fine. Thanks to all of you and The Scripts

Now a new Problem for you people

How to make reports in VB that can display pictures ,,,

I want to recall you all that it is a Gate Pass generation system so I have to make the pass immediately with/after storing the data in database



Thank You
have a nice day
Mar 12 '08 #54
Killer42
8,435 Expert 8TB
Thanks for letting us know how it went.

However, I'd ask that you please post this as a new discussion thread in the VB forum, rather than continuing the comments on this article.
Mar 13 '08 #55
I have this code is asp and it gives me error my my database sta in sql

If Request.TotalBytes > 0 Then
req_bytes = Request.BinaryRead(tot_bytes)
'Parse POSTed request JSON
'Parse POSTed request JSON
reqArgsString = BytesToStr(req_bytes)
reqArgsArray = Split(reqArgsString, "&")
For i = 0 To UBound(reqArgsArray)
reqArgsArray(i) = Split(reqArgsArray(i), "=")
Next

'Decode base64 image from JSON POST to BytesArray'
'Decodificar la imagen base64 de JSON POST a Bytes Array'
base64Encoded = URLDecode(reqArgsArray(1)(1))
base64Decoded = decodeBase64(base64Encoded)
'Response.Write base64Decoded
'' GoTo Done


'DB Connection Object
'Set cn = Server.CreateObject("ADODB.Connection")
'ConnStr="DRIVER=SQL Server;SERVER=161.196.101.140;UID=sa;PWD=P@ssw0rds ql;Database=ContinuumDB"
'cn.Open ConnStr
'Dim strQry
'strQry = "INSERT INTO GA_BLOB (""Blob_Segment"", ""Blob_Person_ID"") VALUES (?, ?)"

' strQry = "INSERT INTO GA_BLOB (""Blob_Person_ID"", ""Blob_Image_ID"", ""Blob_Segment_No"", ""Blob_Format"", ""Blob_Segment"") VALUES (?, ?)"'

'"insert into GA_BLOB (Blob_Person_ID, Blob_Image_ID, Blob_Segment_No, Blob_Format, Blob_Segment) values ('" & Request.form("Blob_Person_ID") & "', '" 0 "','" 0 "','" 0 "', '" & Request.form("Blob_Segment") & "')"'

'Dim cm As ADODB.Command
'Set cm = New ADODB.Command
'cm.ActiveConnection = cn
'cm.CommandText = strQry
'cm.Parameters.Append cm.CreateParameter("@Blob_Segment", adVarBinary, adParamInput, 100, base64Decoded) 'Leave this parameter first
'cm.Parameters.Append cm.CreateParameter("@Blob_Person_ID", adInteger, adParamInput, , reqArgsArray(1)(1))
'cm.CommandType = adCmdText
'cm.Execute
Apr 18 '17 #56

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

Similar topics

2
by: Carolyn Longfoot | last post by:
Help! This is driving me crazy... I'm trying to read a BLOB from a db and display it in a browser, like so: $query="SELECT blob from table where blob_id=9"; $result=mysql_query($query);...
0
by: sandeep G | last post by:
I've a table which has a number & a blob column, both of which are NOT NULL type. This table is composite partitioned using range & hash on the same column. Each partition is sub partitioned into...
1
by: konsu | last post by:
Hello, I am planning to implement an image and movie library (e.g. a photoalbum), and one of the ways that I see to store image and movie files is to put them in to BLOB fields in an sql table....
1
by: torbs | last post by:
I have a problem when I use javascript to get the length and position of a movie I recieve from a rtsp stream. The length and position is extremely high and not the actual length and position of...
4
by: Claus Konrad | last post by:
Hi What's the better way for retrieving a very large BLOB field from a SQL 2000 (image-field)? I'm currently usign a SqlDataReader, but it times out before all data is retrieved from the table...
4
by: aaggarwal | last post by:
Hi All, I'm working on DB2 UDB 8.2 with Fixpack 10 on Windows 2000 Server. The problem I'm facing is that I have created a table having BLOB type column with NOT LOGGED option. (see script...
2
by: Vinciz | last post by:
hi guys... im new in java and i would love to learn some of these... basically i got a sample code to retrieve the blob from the mysql. however, i dont really know what to do with these...
8
by: virtuoso | last post by:
Hi, I'm a beginer in c sharp and I can't pass over a problem. I would like to bind a blob field (mysql) with a picturebox in c sharp; here is the code: string query = "Select...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.