gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
Hi there
A DB Table is brought into a DataTable.
If the value of the long binary field in null it should return a default image, but that is not happening
Here is the PictureBox control
.. and here is the null value function
So far only got round to testing with nullvalues - no errors, but no default image loading either! Any ideas?
Thanks
A DB Table is brought into a DataTable.
If the value of the long binary field in null it should return a default image, but that is not happening
Here is the PictureBox control
VB.NET:
Dim Default_LogoPic As New PictureBox
With Default_LogoPic
.Size = New Point(70, 70)
.Location = New Point(320, 60)
If Form1.AnnualData.Columns.Contains("Logo_Flag") Then
Dim vImage() As Byte = NullImage(Row("Logo_Image"))
Dim vStream As New MemoryStream(vImage)
.Image = Image.FromStream(vStream)
End If
End With
StationaryTab.Controls.Add(Default_LogoCB)
.. and here is the null value function
VB.NET:
Public Function NullImage(ByVal obj As Object) As Byte()
Dim Img As Image = My.Resources.Cross
Dim imgStream As MemoryStream = New MemoryStream()
Img.Save(imgStream, System.Drawing.Imaging.ImageFormat.Png)
imgStream.Close()
Dim byteArray As Byte() = imgStream.ToArray()
imgStream.Dispose()
If Not obj.Equals(DBNull.Value) Then
Dim Str As String = Convert.ToString(obj)
Dim encoding As New System.Text.ASCIIEncoding()
byteArray = encoding.GetBytes(Str)
End If
Return byteArray
End Function
So far only got round to testing with nullvalues - no errors, but no default image loading either! Any ideas?
Thanks