question

Mymikailu-9680 avatar image
0 Votes"
Mymikailu-9680 asked ElevenYu-MSFT answered

Converting a Picture of String Data Type From JSon File To Byte[] Data Type Before Saving to SQL Database

Hi, I have saved a JSon file with Picture to SQL Database and it was saved successfully, but the picture cannot be viewed on Webpage or in Crystal Report. because the Picture was saved as String in the Database. please I nedd a help on how to Convert the JSon File Picture from String to Byte[] before savind


Here below, the code I used!!! Thanks

Dim ScheduleCmd As New SqlCommand("InsertMembers", conn)
With ScheduleCmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@FullName", SqlDbType.VarChar).Value = MemberRecord.FullName.ToString
.Parameters.Add("@Age", SqlDbType.VarChar).Value = MemberRecord.Age.ToString
.Parameters.Add("@marital_status", SqlDbType.VarChar).Value = MemberRecord.marital_status
.Parameters.Add("@Gender", SqlDbType.VarChar).Value = MemberRecord.Gender.ToString
.Parameters.Add("@picture", SqlDbType.VarChar).Value = MemberRecord.picture
End With
'Try
Dim result As Integer = ScheduleCmd.ExecuteNonQuery()
'Catch ex As Exception

                 'End Try
                 ScheduleCmd.Parameters.Clear()
             Next
             InvoiceCmd.Parameters.Clear()
         conn.Close()
     End Using
 End Function


 Public Class Member
     Public Property FullName As String
     Public Property Age As String
     Public Property marital_status As String
 Public Property Gender As String
     Public Property picture As String
 End Class
windows-10-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ElevenYu-MSFT avatar image
0 Votes"
ElevenYu-MSFT answered

Hi,

Not sure if below online tools can help you or not. Please kindly check.

https://onlinestringtools.com/convert-string-to-bytes

https://onlinejsontools.com/convert-json-to-image

Thanks,


If the Answer is helpful, please click "Accept Answer" and upvote it. Thanks.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.