I need to extract images from a database and then show them in unity
and when I do the query I try to save the image in an array of bytes but it does not work. Also, the problem is to pass that array to a visible image.
<WebGet()>
<WebMethod()>
<OperationContract()>
Public Function prueba() As String
Dim dt As New DataTable()
dt.TableName = "Foto"
dt.Columns.Add("foto")
Dim s As String = "SELECT dbo.comedores2.mesa FROM dbo.comedores2"
Dim SqlComman As String = s.ToString
Dim ds As New DataSet()
Using cmd As New SqlCommand(SqlComman, New SqlConnection(conexion))
cmd.Connection.Open()
Dim table As New DataTable()
table.Load(cmd.ExecuteReader())
ds.Tables.Add(table)
cmd.Connection.Close()
End Using
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
Dim byteArray As Byte() = ds.Tables(0).Rows(i).Item("mesa")
dt.Rows.Add(byteArray)
Next
Using dt
Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim rows As New List(Of Dictionary(Of String, Object))()
Dim row As Dictionary(Of String, Object)
For Each dr As DataRow In dt.Rows
row = New Dictionary(Of String, Object)()
For Each col As DataColumn In dt.Columns
row.Add(col.ColumnName, dr(col))
Next
rows.Add(row)
Next
Return serializer.Serialize(rows)
End Using
End Function