473,467 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to convert image file to byte and save to .mdb?

1 New Member
Hello, I was about to create application that can save image from imagebox that has a webcam interface on it. I've been already save the byte but i guess my conversion is wrong because i cant view OLE object data from database to My imagebox.
Error: " Unable to bind to field or DataMember: 'Picture' "
I really need Help. Sorry for my bad english
This is my Whole code on save button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdsave_Click()
  2. OpenDB
  3. rs.Open "tblimg", db, adOpenKeyset, adLockPessimistic, adCmdTable
  4. Dim bytData() As Byte, PicInfo As BITMAP
  5. GetObject Image1.Picture, Len(PicInfo), PicInfo
  6. ReDim bytData((PicInfo.bmWidth * PicInfo.bmHeight * 3) - 1) As Byte
  7. GetBitmapBits Image1.Picture, UBound(bytData), bytData(0)
  8. With rs
  9. .AddNew
  10. .Fields("Picture").AppendChunk bytData
  11. .Fields("Desc") = Label2.Caption
  12. .Update
  13. End With
  14. If Dir(App.Path & "\myPic", vbDirectory) = "" Then MkDir (App.Path & "\myPic")
  15. File1.Path = App.Path & "\myPic"
  16. 'File1.Pattern = "*.bmp"
  17. File1.Pattern = "*.jpg"
  18. File1.Refresh
  19. Dim Maxnum As Integer, ii As Integer
  20. For ii = 0 To File1.ListCount - 1
  21.     If Left(File1.List(ii), 1) = "p" Then
  22.         If CInt(Mid(File1.List(ii), 2, Len(File1.List(ii)) - 4)) > Maxnum Then
  23.             Maxnum = CInt(Mid(File1.List(ii), 2, Len(File1.List(ii)) - 4))
  24.         End If
  25.     End If
  26. Next
  27.     Picture1.Picture = Image1.Picture
  28.     'SavePicture Image1.Picture, App.Path & "\myPic\p" & Maxnum + 1 & ".bmp"
  29.     SAVEJPEG App.Path & "\myPic\p" & Maxnum + 1 & ".jpg", 100, Me.Picture1
  30. Set rs = Nothing
  31. db.Close: Set db = Nothing
  32. End Sub
Feb 28 '16 #1
0 1362

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: William Starr Moake | last post by:
Is there a script to convert image file paths from absolute to just img src="imagename.jpg"? This is for an IE-based WYSIWYG editor. The doImage execCommand produces an absolute file path, which...
1
by: Frank Nero | last post by:
I am trying to write an image to output stream, but can not figure out how to convert System.Web.UI.WebControls.Image to byte . Please give me some hint. Thanks,
0
by: Mike John | last post by:
I trying to browse for an image file and save it to the server image folder. in other words , upload the picture. I tried html and aspx.net code: html:***************************************...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
2
by: su see | last post by:
While dr.Read form = dr("form") Dim img As Image Dim b() As Byte b = form If b.Length > 0 Then Dim stream As New MemoryStream(b, True) stream.Write(b, 0, b.Length)
8
by: piggy | last post by:
I am trying to convert an image to an byte array (tobytes() method) and from byte array back to an image (frombytes() method). The problem i have here is say the image size is 285 bytes but the...
3
by: Raghu Raman | last post by:
Hi i want to save the read the image file and show it on a image control of a mobile webform .But the mobile control does not support html images ,so i am forced to use the server image control...
2
by: abdulprav | last post by:
hi, can any body help me to convert the contents of java output to text file praveen
2
by: sbs | last post by:
hi all of u , in my project i want to transfer an image from one moblie to another mobile using bluetooth. i have written a code but giving null pointer exception at int length = in.read(buff); ...
3
by: mrcw | last post by:
Hi I'm trying to save a webcam image to a 24 bpp bmp using pictureBox1.Image.Save("c:/users/Mark/Desktop/pictureBox1.Bmp", System.Drawing.Imaging.ImageFormat.Bmp); but I keep on getting the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.