How to convert string bytes into bytes[] and save into database
<p>I have some JSON data which contains an image field with bytes. I want to save these bytes into a database, but I am not able to convert the string into a byte array.</p>

<pre><code>{
    "trackid": "TRXh82URBNA2878934",
    "serviceid": "66",
    "category": "URBN",
    "name": "sachin",
    "description": "Sanitations Work",
    "location": "Greater Noida",
    "requesterlocation": "new delhi",
    "email": "sachin@gmail.com",
    "contact_number": "882379823",
    "latitude": "78.23",
    "longitude": "30.23",
    "locationtype": "urban",
    "sectorid": "12",
    "userid": "34",
    "filename": "IMG001",
    "extension": ".jpg",
    "contenttype": "image/jpeg",
    "image": "0xFFD8FFE13F5745786966000049492A000800000012000E01020020000000E60000000F01020020000000060100001001020020000000260100001201030001000000010000001A01050001000000460100001B010500010000004E01000028010300010000000200000031010200200000005601000032010200140000007601000013020300010000000200000020020400010000000000000021020400010000000000000022020400010000000000000023020400010000000000000024020400010000000100000025020200200000008A0100006987040001000000AA01000025880400010000002C0300004504000000000000000000000000000000000000000000000000000000000000000000004F50504F000000000000000000000000000000000000000000000000000000005839303039000000000000000000000000000000000000000000000000000000480000000100000048000000010000004D6564696154656B2043616D657261204170706C69636174696F6E0A00000000323031363A31303A32312030393A34383A323200000000000000000000000000000000000000000000000000000000000000000019009A82050001000000DC0200009D82050001000000E40200002288030001000000000000002788030001000000320000000090070004000000303232300390020014000000EC02000004900200140000000003000001910700040000000102030004920A0001000000140300000792030001000000020000000892030001000000FF000000099203000"
}
</code></pre>

<p>I am facing an error while inserting the byte string into the database.  Here is my code:</p>

<pre><code>SqlCommand cmd = new SqlCommand("PROC_INSERT_CITIZENT_REQUEST_DOCUMENTS_FOR_WEB_API");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = Connection;
Connection.Open();
cmd.Parameters.AddWithValue("@P_Cititzen_request_recno", oRequest.requestid);
cmd.Parameters.AddWithValue("@P_Category", oRequest.category);
cmd.Parameters.AddWithValue("@P_Filename", oRequest.filename);
cmd.Parameters.AddWithValue("@P_extension", oRequest.extension);
cmd.Parameters.AddWithValue("@P_contentType", oRequest.contenttype);
//byte[] newBytes = Convert.FromBase64String(oRequest.image);
cmd.Parameters.AddWithValue("@P_Doc_Data", Encoding.UTF8.GetBytes(oRequest.image));
cmd.Parameters.AddWithValue("@P_MSG", "");

j = cmd.ExecuteNonQuery();
if (j &lt; 1)
{
    j = 0;
}
</code></pre>

<p>What am I doing wrong?</p>