473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

saving and retrieving pictures using vb6 and ms access

Hi
Am developing a school software and i have a form named Admission which i want to include the pictures of students, i have managed to upload the picture using this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  Dim pic As StdPicture
  3. dlgPicture.Filter = "Pictures (*.bmp;*.jpg)|*.bmp;*jpg|"
  4. dlgPicture.ShowOpen
  5. filen = dlgPicture.FileName
  6. Picture1.Picture = LoadPicture(filen)
  7. End Sub
The problem now is how to save and retrieve those pictures. Am using VB6.0 connecting to MS Access database using module and i want pictures to be saved in table admission field called images
Can someone please help!
Jun 20 '13 #1
4 23604
Mihail
759 512MB
As far as I know (maybe I am wrong), a picture can't be stored in Access database. But the picture path can.

Assuming that you already have a form bounded to table Admission, create a new field (Student_Pic) in this table and store here the path(s) to every student picture.

Then manage that your Picture control to be updated using the properly path (the path stored in the new created field).

Hope this is a help for you.
Jun 22 '13 #2
Killer42
8,435 Expert 8TB
Actually, this topic has been covered here more than once. Try the search box.

I did a quick search for the terms "vb access save image" and found a couple of likely-sounding entries...
Jul 14 '13 #3
thanks guys i was able to save and retrieve pictures using this code:
Expand|Select|Wrap|Line Numbers
  1. Dim arrImageByte() As Byte
  2.     Dim fNum As Integer
  3.  
  4.     Dim rs As New ADODB.Recordset
  5.     Dim strPhotoPath As String
  6.     Dim isImage As Boolean
  7.     If Me.imgPhoto.Picture <> LoadPicture("") Then
  8.         SavePicture Me.imgPhoto.Picture, App.Path & "\tmpphoto.jpg"
  9.         strPhotoPath = App.Path & "\tmpphoto.jpg"
  10.  
  11.         ReDim arrImageByte(FileLen(strPhotoPath))
  12.         fNum = FreeFile()
  13.         Open strPhotoPath For Binary As #fNum
  14.         Get #fNum, , arrImageByte
  15.         Close fNum
  16.  
  17.         isImage = True
  18.     End If
  19.  
  20.     rs.Open "student", conn, adOpenStatic, adLockOptimistic, adCmdTable
  21.  
  22.     With rs
  23.         .AddNew
  24.         .Fields("Name") = Me.txtName.Text
  25.  
  26.         If isImage = True Then _
  27.             .Fields("photo").AppendChunk arrImageByte
  28.         .Update
  29.  
  30.     End With
  31.  
  32.     rs.Close
  33.     Set rs = Nothing
Jul 15 '13 #4
Killer42
8,435 Expert 8TB
Glad to see you found a solution, and thanks for sharing it. This will be helpful for others who come searching with similar questions.

I think it'd be fair to say that pretty much anything you can get into your computer can be stored in your database, somehow.

As Mihail said, you could store the images elsewhere and just include some sort of link in the database. I personally find it more convenient to keep everything together in the database. Each approach has its good and bad points.

Don't forget to take into consideration what this image will do to your record size. If you do come across any database issues, keep in mind our Access Forum.
Jul 16 '13 #5

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

Similar topics

2
by: Bill | last post by:
For a variety of user-driven reasons, we're using an Access DB on a Desktop as the repository for data we transfer to/from a Pocket PC 2002 Application that uses SQL-CE. Have not yet located a...
3
by: JED | last post by:
I have an opportunity to work on a web based project using Access. However, there has been a suggestion that MySQL might be a better alternative. The project is actually a small project (less than...
5
by: dananrg | last post by:
I've created a small company database where the tables reside in a SQL Server database. I'm using Access 2000 forms for a front end. I've got a System DSN set-up to SQL Server and am using links...
4
by: meyvn77 | last post by:
Background: I'm new at SQL Server (no experience, zip, nada) but getting pretty good with developing applications in Access(VBA) and in VB using ADO.... Currently I use access to and GIS...
3
by: bill mahoney | last post by:
Hello, I am using access 2000 and I am trying to email a csv file. I have only used the docmd.sendobject command but you can only email objects that are within the access database ( as far as I...
3
by: Steven | last post by:
i want to be able to find jpeg's in a certain directory on my server and then link them to an id and display them in a form. at present the table is very basic but i am struggling on how to make...
6
by: Serious_Practitioner | last post by:
Good day all, and thank you in advance for your help. No - MANY thanks in advance for your help - I know nothing about using databases on Web servers. I am about to discuss a project with a...
4
by: Bugs | last post by:
Hi everyone. I am trying to open a database which works fine using Access 2003, but when trying to open it on another PC that has Access 2002 I get the following error "This database is...
3
by: Bruce | last post by:
I have a number of Access 2000 format databases on a Windows 2003 server. For some reason I can no longer compact these databases directly on the server using Access 2003. Access 2000 seems to...
3
Fary4u
by: Fary4u | last post by:
http://www.furyconcept.co.uk/db.jpg attach file contains database table, retrieving value using multiple array, no problem retrieving 1st values but when i'm trying to retrieving 2nd array value...
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: 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
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
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.