Save picture in access

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2007
Posts: 23
Reputation: poonams is an unknown quantity at this point 
Solved Threads: 0
poonams's Avatar
poonams poonams is offline Offline
Newbie Poster

Save picture in access

 
0
  #1
Jan 1st, 2008
hi all


I can anyone tel me how to save image in access database.& also hw to access image from database.I don't know how to start.plz reply
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Save picture in access

 
0
  #2
Jan 7th, 2008
What version of Access are you using? I believe 2007 is the only version to allow saving an image. You could save the image in a folder and place the image path in the db and pull it that way.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2
Reputation: Krisha is an unknown quantity at this point 
Solved Threads: 0
Krisha Krisha is offline Offline
Newbie Poster

Re: Save picture in access

 
0
  #3
Aug 27th, 2008
Originally Posted by poonams View Post
hi all


I can anyone tel me how to save image in access database.& also hw to access image from database.I don't know how to start.plz reply
'===========================
Private Sub KS_SaveImage()
Try
Dim KS_FO As New OpenFileDialog
KS_FO.Title = "Select Image"
KS_FO.Filter = "Images(jpeg)|*.jpeg"
KS_FO.ShowDialog(Me)
' now going to open selected file
Dim KS_FS As New FileStream(KS_FO.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim KS_BytesOFfile(KS_FS.Length - 1) As Byte
KS_FS.Read(KS_BytesOFfile, 0, KS_BytesOFfile.Length)
'DB properties
Dim DBpath As String = Application.StartupPath & "\KSimg.mdb"
Dim KS_Con As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBpath)

Dim Sqlstatment As String = "INSERT INTO tblImg ([img],[size]) VALUES (?,?)"

Dim Cmd As New System.Data.OleDb.OleDbCommand(Sqlstatment, KS_Con)
Cmd.Parameters.Add("@Pic", System.Data.OleDb.OleDbType.Binary, KS_FS.Length).Value = KS_BytesOFfile
Cmd.Parameters.Add("@FileSize", System.Data.OleDb.OleDbType.Numeric, 100).Value = KS_BytesOFfile.Length
KS_Con.Open()
Cmd.ExecuteNonQuery()
KS_Con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
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 VB.NET Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC