saving image in ms access using vb6

Thread Solved

Join Date: Oct 2009
Posts: 4
Reputation: venkatnams is an unknown quantity at this point 
Solved Threads: 0
venkatnams venkatnams is offline Offline
Newbie Poster

saving image in ms access using vb6

 
0
  #1
18 Days Ago
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]
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #2
17 Days Ago
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.
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 4
Reputation: venkatnams is an unknown quantity at this point 
Solved Threads: 0
venkatnams venkatnams is offline Offline
Newbie Poster
 
0
  #3
17 Days Ago
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,,,
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #4
17 Days Ago
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.
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 4
Reputation: RobCr is an unknown quantity at this point 
Solved Threads: 1
RobCr RobCr is offline Offline
Newbie Poster
 
0
  #5
17 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #6
17 Days Ago
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).
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 471
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 24
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training
 
0
  #7
16 Days Ago
plz try it.
Attached Files
File Type: zip photo.zip (1.66 MB, 19 views)
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #8
16 Days Ago
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.
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 4
Reputation: venkatnams is an unknown quantity at this point 
Solved Threads: 0
venkatnams venkatnams is offline Offline
Newbie Poster
 
0
  #9
16 Days Ago
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,088
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 125
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic
 
1
  #10
16 Days Ago
try the following code, make changes as desired

  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
Share your Knowledge.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC