picture saving in database. problem

Reply

Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

picture saving in database. problem

 
0
  #1
Jan 30th, 2008
hi.. i tried to put picture on our system. in the employee form.. but i dont know the exact step on how.


i have here a code for opening the picture.. but i dont know how to save it in my database together with the information of the employee... here my code


cd.Filter = "PictureFile(*.jpg,*.bmp,*.gif)|*.jpg|*.gif|*.bmp|"
cd.ShowOpen
Image1.Picture = LoadPicture(cd.FileName)

i tried to use a field with an oleobject but i dont know how to work well..

this my saving procedure


Sub saverecord()

rsemployee.AddNew
rsemployee.Fields("EmployeeID") = txt1.Text
rsemployee.Fields("EmployeeName") = txt2.Text
rsemployee.Fields("EmployeePosition") = txt3.Text
rsemployee.Fields("Address") = txt4.Text
rsemployee.Fields("Age") = txt5.Text
rsemployee.Fields("Gender") = txt6.Text
rsemployee.Fields("PhoneNo") = txt7.Text
rsemployee.Fields("picture") = cd.FileName
rsemployee.Update



End Sub

i need an clear stepss...kindly help me....

thxxxxxxx

jaasaria
Last edited by jaasaria; Jan 30th, 2008 at 9:21 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: picture saving in database. problem

 
1
  #2
Jan 30th, 2008
i guest u want to save path of the picture.
this way is the easiest. but you must to put the picture on one folder. don't try to move the picture that you was saved it. if you move the picture, you will get an error..
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 1
Reputation: ptolchin is an unknown quantity at this point 
Solved Threads: 0
ptolchin ptolchin is offline Offline
Newbie Poster

Re: picture saving in database. problem

 
2
  #3
Jan 30th, 2008
Last edited by ptolchin; Jan 30th, 2008 at 3:05 pm. Reason: Whole Url wasnt showing
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: picture saving in database. problem

 
0
  #4
Jan 30th, 2008
can you give me the exact process??
on how to make that picture saving..

even that it has the disadvantages.. i would like see the way it process..

thxx alwayzzzzzzzzzz
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: picture saving in database. problem

 
0
  #5
Jan 30th, 2008
hi jaasaria,
>>can you give me the exact process??
what of exact process?
are u have visiting the site from ptolchin?
in there you can see the faq about this thread.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: picture saving in database. problem

 
0
  #6
Jan 31st, 2008
thxxxxxxx for the help.... thxx a lot guyzzzzzzz
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,094
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: picture saving in database. problem

 
0
  #7
Feb 5th, 2008
It is always better to store the picture in a LOB field in database after converting the file into a byte stream . It ensures that no data is lost . So you don't have to bother about location of all the files.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: picture saving in database. problem

 
0
  #8
Feb 5th, 2008
elow... can you make it step 2 step..
actually im only novice in vb...

can i??
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,094
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: picture saving in database. problem

 
0
  #9
Feb 5th, 2008
Try to use this sample code

  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  
Join Date: Jul 2007
Posts: 113
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

Re: picture saving in database. problem

 
0
  #10
Feb 6th, 2008
thx a lot dude......thxxxxx for sharing your knowledge..^_^
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC