943,884 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 9488
  • VB.NET RSS
Jan 1st, 2008
0

Save picture in access

Expand 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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poonams is offline Offline
23 posts
since Oct 2007
Jan 7th, 2008
0

Re: Save picture in access

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.
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Aug 27th, 2008
0

Re: Save picture in access

Click to Expand / Collapse  Quote originally posted by poonams ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Krisha is offline Offline
2 posts
since Dec 2006

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 VB.NET Forum Timeline: Removing First Line Of Text From multiline textbox
Next Thread in VB.NET Forum Timeline: Process monitor





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


Follow us on Twitter


© 2011 DaniWeb® LLC