Uploading jpeg picture to ms access via Visual basic 6

By chatingkrew ·
I am currently designing a program (Project work) using visual basic 6, ms access 2000 as a database. my question is that i want to know a code that will enable one to upload a picture (JPEG) via vb6 into the ms access 2000 database. pls note this is not online but on standalone computer.

thank you.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Images in database?

by onbliss In reply to Uploading jpeg picture to ...

You can store the images in the Access database using an OLE Object field. This does increase the record size and consequently the database size.
Alternatively, you can store the images on a local drive/path and store the full path in one of the records. You can write VBA code to display (load ) images. This keeps the size of the database in check, but adds the onus to ensure images are backed up and not deleted through the file system.

Collapse -

Images in database?

by mmveke In reply to Images in database?

I think onbliss has the perfect solution for you, just make sure you store the pictures in the same folder as your database and make sure they are backed up with your database

Collapse -

Can you provide more guidelines

by udara_fdo In reply to Images in database?

I need to know the sample coding has to be done to upload the picture to that folder and review the pictures to a command and how to delete a particular photo whenever I need

Collapse -

Use ADO.Stream

by kevin.stafferton In reply to Images in database?

I did a similar thing in Acess VBA
only storing an Excel workbook in the database.

First load the image into an ADO stream object.

Set st = new
st.Type = adTypeBinary
st.LoadFromFile "imagefilename"

The read the stream into the OLE field value.

.Fields("Fieldname").Value = st.Read()

Collapse -

Insert Picture in access table and Display in Image Box on Form

by trimurarisingh In reply to Use ADO.Stream

Dim FileLength As Long
Dim Numblocks As Integer
Dim LeftOver As Long
Const BlockSize = 1000000 'This size can be experimented with for
Dim ByteData() As Byte 'Byte array for picture file.
Dim DestFileNum As Integer
Dim DiskFile As String
Dim rr As Integer

''''''''''''''''''Insert Picture in Table'''''''''''''''''''
If Trim(CommonDialog1.FileName) = "" Then
CommonDialog1.FileName = "App.path & "\photo.jpg"
End If

Open CommonDialog1.FileName For Binary As #1
ReDim MyArray(LOF(1))
Get #1, , MyArray()
Close #1
''''''''''''insert picture in table''''''''

RSDetails.Fields("emp_photo").AppendChunk MyArray()
''Rsdetails is the recordset of table'''
'''"emp_photo" is field's of table'''
''Appendchunk is use for load image in table''

''''''''''''''Display Picture In Image OR PictureBox From Table'''''''''''
DiskFile = "App.path & "\photo.jpg"

If Len(Dir$(DiskFile)) > 0 Then
Kill DiskFile
End If

DestFileNum = FreeFile
Open DiskFile For Binary As DestFileNum
FileLength = TempDetails("emp_photo").ActualSize
Numblocks = FileLength / BlockSize
LeftOver = FileLength Mod BlockSize

ByteData() = TempDetails("emp_photo").GetChunk(LeftOver)
Put DestFileNum, , ByteData()

For I = 1 To Numblocks
ByteData() = TempDetails("emp_photo").GetChunk(BlockSize)
Put DestFileNum, , ByteData()
Next I

Close DestFileNum
Image1.Picture = LoadPicture("App.path & "\photo.jpg")
'''''''''''''''end modifiction section'''''''''''''''

Collapse -


by nitesh09911 In reply to Uploading jpeg picture to ...

ms access is not support to upload a picture in ur data base,becoz ms access is not support that type of data type(data type is blob) u can upload image through mysql

Collapse -

Complete rubbish

by kevin.stafferton In reply to hiiii

Access has a datatype of OLE Object that can store any kind of binary data you like, just like BLOBs.

I suggest you read other people's replies before spreading misinformation like this.

Collapse -

required technique

by majumder.goutam In reply to Uploading jpeg picture to ...

how store image in ms access database

Related Discussions

Related Forums