944,200 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 8th, 2009
0

saving image in ms access using vb6

Expand Post »
hello everybody,
im venkat doing my b.e 3rd year... Im currently working on my project of college administration system using vb6.
I need help on how to save an image in the access database...i have got the code on how to browse an image. but i'm not able to find out how to save it to a particular record on a database.
So please help me in this,,thanx in advance
[/B]
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
venkatnams is offline Offline
21 posts
since Oct 2009
Nov 9th, 2009
0
Re: saving image in ms access using vb6
Do you want to save the file name or the image?

Your question is unclear for the purpose of your request.

If you want to have the image to show in the form, you can only do it from a file so LoadPicture() the image to the form preferable to a frame or other picture object to store the image.
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
Nov 9th, 2009
0
Re: saving image in ms access using vb6
i need to save the image file...that is, if i register a new name i'll be having a option for photo uploading in the same form itself,,,,i need to save that photo by browsing the computers folders just like how we upload files, and after choosing a image file i need to save it to the particular record itself,,,im not talking about the name of the image but im talking about saving the image itself, So if we search for that name i'l be getting all his details including a photo....i hope u understand,,,
Reputation Points: 10
Solved Threads: 0
Newbie Poster
venkatnams is offline Offline
21 posts
since Oct 2009
Nov 9th, 2009
0
Re: saving image in ms access using vb6
You mean you want to load the picture into the form?

LoadPicture will do this but like I say, VB6 only accepts *.bmp, *.gif, *.jpg but not other formats. It might accepts *.tif images but am not sure.

Still not sure about what you say. Saving is not the correct term to use. You either load the picture into a userform or you add the filename to the record for referencing.

Perhaps you want to copy the image file into your own folder?

You cannot put a file into a record. A record is just a data file that lists your data.
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
Nov 9th, 2009
0
Re: saving image in ms access using vb6
There is a means to store the image, but I have never attempted that.
You could end up with a rather large DB.
Why not create a sub folder in the same location as the DB.
Then have sub folders for each ID (Student ID ?)
Place the image in there.
Your program can retrieve the image any time in the future, as the program knows where to find the folder, and it knows the Student ID to locate that Student's sub folder.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
RobCr is offline Offline
6 posts
since Dec 2006
Nov 9th, 2009
0
Re: saving image in ms access using vb6
RobCr - thanks for your input. I actually hate Access but know a bit about VB6.

venkatnams - RobCr says it can be done but it may bloat your database. I suggest if it is for student ID cards, to put the images into a sub folder then "Call each image as you need it into a form. Add Stuednt details to the form then print the ID Card (if this is the purpose of the project).
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
Nov 9th, 2009
0
Re: saving image in ms access using vb6
plz try it.
Attached Files
File Type: zip photo.zip (1.66 MB, 1671 views)
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Nov 10th, 2009
0
Re: saving image in ms access using vb6
Chambutton.ocx? I've never heard of that. Did you create it yourself?

Data1.Recordset.AddNew - What does Data1 refer to?

Are you trying to access an Accesss database from outside of Access?
Access has it's own userform facility where you can access the database. I think you need an Sql event to open the database. I also think that if the user does not actually have Acess on the computer, accessing the mdb file will be hard to do as I believe that you can only acceess the file if the user has the software that created the file in the first place. Unless you are savvy to extracting data from a file, this is a hard task project.
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
Nov 10th, 2009
0
Re: saving image in ms access using vb6
thanx for the file...i ran it,,it worked fine...but my aim is not only to view...i need to save it in access against a particular id,,,
please check the following link::
http://s924.photobucket.com/albums/a...nt=project.jpg

i hope you understand the scenario now,,

waiting for ur response,,
thank you
Reputation Points: 10
Solved Threads: 0
Newbie Poster
venkatnams is offline Offline
21 posts
since Oct 2009
Nov 10th, 2009
1
Re: saving image in ms access using vb6
try the following code, make changes as desired

vb Syntax (Toggle Plain Text)
  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 cmdSave_Click()
  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, adLockOptimistic
  15.  
  16. RS.AddNew
  17. SavePicture
  18. RS.Update
  19.  
  20. Set RS = Nothing
  21. Set RS = New Recordset
  22. End Sub
  23.  
  24. Private Sub SavePicture()
  25. Dim strFileNm As String
  26. DataFile = 1
  27. Open strFileNm For Binary Access Read As DataFile
  28. Fl = LOF(DataFile) ' Length of data in file
  29. If Fl = 0 Then Close DataFile: Exit Sub
  30. Chunks = Fl \ ChunkSize
  31. Fragment = Fl Mod ChunkSize
  32. ReDim Chunk(Fragment)
  33. Get DataFile, , Chunk()
  34. RS!logo.AppendChunk Chunk()
  35. ReDim Chunk(ChunkSize)
  36. For i = 1 To Chunks
  37. Get DataFile, , Chunk()
  38. RS!logo.AppendChunk Chunk()
  39. Next i
  40. Close DataFile
  41. End Sub
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: SQL command for calculating Ave from multiple tables
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 Form Refresh help Request





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC