Here is the code I tried to store the data in binary format for the uploaded file...................
protected void Button1_Click(object sender, EventArgs e)
{
int PartyRowId = 0;
foreach (UploadedFile file in AsyncUpload1.UploadedFiles)
{
byte[] bytes = new byte[file.ContentLength];
file.InputStream.Read(bytes, 0, Convert.ToInt32(file.ContentLength));
string json3 = "{'value1':" + value+ ",'value2':" + value+ ",'value3':" + value+ ",'PartyDoc':" + bytes + "}";
}
}
i got the Json as
{'value1':0,'value2':0,'value3':0,'PartyDoc':System.Byte[]}
not able to retrieve the binary data Please help me......
You should use Convert.ToBase64String();
string json3 = "{'value1':" + value+ ",'value2':" + value+ ",'value3':" + value+ ",'PartyDoc':" + Convert.ToBase64String(bytes) + "}";
Then on the other side you can use Convert.FromBase64String();
done with the conversion as below...
CONVERT(varbinary(100), CONVERT(varchar(max),@variable))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.