Dear sir
I m Software Engineer in Software co.
My question is how do i Store OLE Object (JPG) file to database
AppendChunk
plz Help me
7 12558
Pass the OLE Picture Object and the ADO Database field to the following code. It's not pretty since it uses an intermediate Windows File, but it is the shortest piece of code I know. There are other methods using In Memory files, etc.
To be honest I use the LEAD Tools Image Object that has a SAVE command.
Neon K. -
-
Public Sub WriteImage(ByRef pPict As StdPicture, ByRef pField As ADODB.Field)
-
-
On Error Resume Next
-
-
Dim strStream As New ADODB.Stream
-
-
strStream.Type = adTypeBinary
-
strStream.Open
-
Call SavePicture(pPict, "TempTemp.bmp")
-
strStream.LoadFromFile ("TempTemp.bmp")
-
pField.Value = strStream.Read
-
Kill "TempTemp.bmp"
-
strStream.Close
-
-
End Sub
-
Hi there,
below are some sample to store and to retrieve images from and to BLOB field.. give it a try..
retrieve from BLOB field -
Public Sub getBLOB(RS As ADODB.Recordset, Field As String, Des As String)
-
Dim lngFieldSize As Long
-
Dim fileBytes() As Byte
-
Dim intFileHandle As Integer
-
-
intFileHandle = FreeFile
-
-
lngFieldSize = RS(Field).ActualSize
-
If lngFieldSize > 0 Then
-
fileBytes = RS(Field).GetChunk(lngFieldSize)
-
Open Des For Binary As intFileHandle
-
Put intFileHandle, , fileBytes
-
Close intFileHandle
-
End If
-
End Sub
-
store to BLOB field -
Public Sub setBLOB(RS As ADODB.Recordset, Field As String, Source As String)
-
Dim fileBytes() As Byte
-
Dim intFileHandle As Integer
-
-
intFileHandle = FreeFile
-
-
Open Source For Binary As intFileHandle
-
fileBytes = InputB(LOF(intFileHandle) - 1, intFileHandle)
-
RS(Field).AppendChunk fileBytes
-
Close intFileHandle
-
End Sub
-
sample usage -
setBLOB myRecordSet, "FileField", "c:\myfile.gif" ' Places file into database
-
-
getBLOB myRecordSet, "FileField", "c:\myfile_extracted_from_database.gif"
-
good luck my fren.. :)
Hi there,
below are some sample to store and to retrieve images from and to BLOB field.. give it a try..
retrieve from BLOB field -
Public Sub getBLOB(RS As ADODB.Recordset, Field As String, Des As String)
-
Dim lngFieldSize As Long
-
Dim fileBytes() As Byte
-
Dim intFileHandle As Integer
-
-
intFileHandle = FreeFile
-
-
lngFieldSize = RS(Field).ActualSize
-
If lngFieldSize > 0 Then
-
fileBytes = RS(Field).GetChunk(lngFieldSize)
-
Open Des For Binary As intFileHandle
-
Put intFileHandle, , fileBytes
-
Close intFileHandle
-
End If
-
End Sub
-
store to BLOB field -
Public Sub setBLOB(RS As ADODB.Recordset, Field As String, Source As String)
-
Dim fileBytes() As Byte
-
Dim intFileHandle As Integer
-
-
intFileHandle = FreeFile
-
-
Open Source For Binary As intFileHandle
-
fileBytes = InputB(LOF(intFileHandle) - 1, intFileHandle)
-
RS(Field).AppendChunk fileBytes
-
Close intFileHandle
-
End Sub
-
sample usage -
setBLOB myRecordSet, "FileField", "c:\myfile.gif" ' Places file into database
-
-
getBLOB myRecordSet, "FileField", "c:\myfile_extracted_from_database.gif"
-
good luck my fren.. :)
Is there any other method to do this?
because after using this code it stores image as Long binary data. If you do the same With using MsAccess's form, it stores as Bitmap file. If we are handling Big database, then above example will make any differance to speed of accessing database?
Plz reply waiting
Hi there,
Another option will be converting BMP to JPG format respectively, take a look at below attached link, hope it helps. Good luck & take care. http://www.vbaccelerator.com/home/VB...ry/article.asp
Is there any other method to do this?
because after using this code it stores image as Long binary data. If you do the same With using MsAccess's form, it stores as Bitmap file. If we are handling Big database, then above example will make any differance to speed of accessing database?
Plz reply waiting
im also looking and still in progress of implementation "How do i store OLE Object (JPG) file to database( MS-ACCESS and SQL SERVEr2000) for my recent project..as soon as i will provide whole source code.in .ZIP format
take care
from geoamins.uni.cc
hi co-scrpiters
would you send me a running visual basic code for uploading and retrieving images from mysql database?
here is my email address mil id removed
please....
because i tried so many codes that i have seen over the net but none of them will run... i think there something maybe on my code that i have to refresh..
please send it to me... it will be very much appreciated...
thnx all and god bless us all scripters...
ikebiz...
Please find related discussions here and here .
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lars Behrens |
last post by:
Hi there!
For a web project I need a little expert help. I don't have written much
code yet, just been fiddling around a bit, testing and planning.
The web site will have a submission page for...
|
by: David Stockwell |
last post by:
Hi,
I'd like to read the contents of a file into memory. The problem is that
this file is binary. I then want to store the whole thing in memory to a
database as a blob.
I have no problem...
|
by: Karen Grube |
last post by:
Hi!
Each week, we receive a two-page PDF file from UPS along with a separate
flat file (a CSV) The PDF file contains the overview of our weekly invoice
and the CSV contains the details of each...
|
by: DL |
last post by:
Hi,
Many questions have already been asked and answered about images in
Access... But despite having searched, I have not found an answer to
the following question...
In my DB, several forms...
|
by: nigel.thomson |
last post by:
Hello All
Is there an easy way to do this?
I have a database that contains records witha image as one of the
fields, what I want to do is export the images to a seperate folder, in
whatever...
|
by: Paul Cheetham |
last post by:
Hi,
I am developing an application that needs to store some machine-specific
settings. The application is going to be published on the network in
order to keep the clients on the latest version....
|
by: JM |
last post by:
Before storing information from a form in database I perform follwing
operations on it :
$path =
mysql_real_escape_string(strip_tags(trim(urldecode($_POST))));
$summary =...
|
by: harshad |
last post by:
Dear All,Here I am facing problem to store image.I am trying to store byte
array(image) in to session variable so at time of update I will got that
byte array and I do my update. here i am given...
|
by: gm000 |
last post by:
hi
i m using radiobuttonlist with images like this
<asp:RadioButtonList ID="rbtnthumb1" runat="server">
<asp:ListItem Value ="News_icon.jpg">
<img...
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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,...
| |