473,388 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

convert a byte array to an image that will display in a PictureBox on a VB form data

Expand|Select|Wrap|Line Numbers
  1.  sql = "SELECT  RecordNum, DelDate, FName, Lname, Phone, Email, DevMake, DevModel, Carrier, DevColor, UsserPassword, MobileId, Repaired, RepComments, ServiceType, FindUs, DateDone, AuthorizeRepair, BackUpInfo, TecTrained, NotResponsible, VoidWarranty, FeesPaid, DiagnosticFee, Pricequote, Deposit, Total, signature  FROM RepairData ORDER BY Lname"
  2.         Dim imgMemoryStream As MemoryStream = New MemoryStream()
  3.         da = New OleDb.OleDbDataAdapter(sql, con)
  4.         da.Fill(ds, "RepairData")
  5.  
  6.         Dim c As Integer = ds.Tables("RepairData").Rows.Count
  7.         If c > 0 Then
  8.             Dim n As Integer
  9.             For n = 1 To c
  10.                 If ds.Tables("RepairData").Rows(n - 1)("signature") IsNot DBNull.Value Then
  11.                     Debug.WriteLine(ds.Tables("RepairData").Rows(n - 1)("signature"))
  12.                     Dim imageBytes() As Byte = _
  13.                         DirectCast(ds.Tables("RepairData").Rows(n - 1)("signature"), Byte())
  14.                     Dim myStream As New MemoryStream(imageBytes)
  15.                     ds.Tables("RepairData").Rows(n - 1)("signature") = Image.FromStream(myStream) 'error myStream here
  16.  
  17.                 End If
  18.             Next
  19.         End If
Using the above code. I have found it on the internet in several places but I get an invalid parameter error for myStream variable in the Image.FromStream (myStream) code.
Feb 16 '18 #1
2 2132
Luuk
1,047 Expert 1GB
"Image" is not declared in the piece of code you have copied here. that is making it hard to guess which parameters are missing.

Also bytes.com provides a '[CODE/]' button for copying/pasting pieces of code in a message...
Feb 17 '18 #2
Frinavale
9,735 Expert Mod 8TB
What are you trying to do on these lines?
Expand|Select|Wrap|Line Numbers
  1.  Dim myStream As New MemoryStream(imageBytes)
  2.                     ds.Tables("RepairData").Rows(n - 1)("signature") = Image.FromStream(myStream) 'error myStream here
Are you attempting to set the "signature" column for the row in the data table to a Stream?????

Why?

Shouldn't you be creating a new image and then applying it where needed?

For example:
Expand|Select|Wrap|Line Numbers
  1. If ds.Tables("RepairData").Rows(n - 1)("signature") IsNot DBNull.Value Then
  2.   Debug.WriteLine(ds.Tables("RepairData").Rows(n - 1)("signature"))
  3.   Dim imageBytes() As Byte = DirectCast(ds.Tables("RepairData").Rows(n - 1)("signature"), Byte())
  4.  
  5.   Using ms As New IO.MemoryStream(imageBytes)
  6.     Dim imageFromStream As Drawing.Image = Drawing.Image.FromStream(ms)
  7.     'Use the image appropriately  
  8.   End Using
  9. End If
  10.  
Feb 21 '18 #3

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

Similar topics

6
by: Gator | last post by:
Hi All, Basically my situation is this, I have a server implemented in C++, unmanaged code, using proprietery protocol over TCP/IP to communicate with the cilent(c++ also). Now, I am implementing...
2
by: Dave | last post by:
Hi, I'm trying to convert a byte array to string --This works... System.BitConverter.ToString(bytes) "EB-55-79-20-18-B2-76-4D-85-0A-93-6B-97-33-31-B8" --This doesn't, but returns...
14
by: Charles Law | last post by:
I thought this had come up before, but I now cannot find it. I have a byte array, such as Dim a() As Byte = {1, 2, 3, 4} I want to convert this to an Int32 = 01020304 (hex). If I use...
18
by: MrVS | last post by:
Hi, I have a C++ CLR class method that takes System::Byte *b as parameter argument. I want the CSharp caller pass a byte * to this function. But in the CSharp prorgram, I only managed to create a...
2
by: GauravRashinkar | last post by:
How to convert byte array into a image? Byte photo = Convert.FromBase64String(value); //System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); //Byte...
1
by: Alan Mather | last post by:
calculated subform fields will display on form but won't save in table
2
by: ISH777 | last post by:
Hello Everyone, I have a Problems Regarding with the IMAGE I create a Program That save Information of END USERS including Image... but the Image will save into Bytes.....and I have no Problem...
8
by: Mapel | last post by:
Hi, I tried to convert byte array with hex to equivalent decimal value as follows but it gives me unexpected results: byte hex_arr = { 0x00, 0x01, 0xab, 0x90}; unsigned long i=0; i = hex_arr +...
3
by: doubler | last post by:
I have a Windows app created in VS2012. I'm calling a web service that is returning a pdf as a byte array. I want to convert the array back to a pdf and display it to the user without having to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.