I know how to insert binary data of a .zip file into a new SQL Server row into a column of datatype NVARCHAR(MAX).
Need help to update existing column of NVARCHAR(MAX) of row with binary data from a .zip file. Code below works but converting binary to file again renders an defect zip file:
byte[] file;
using (var stream = new FileStream(zipFile, FileMode.Open, FileAccess.Read))
{
using (var reader = new BinaryReader(stream))
{
file = reader.ReadBytes((int)stream.Length);
}
}
rowColumn = file;
While this works with INSERT with code:
cmd.Parameters.Add("@rowColumn", SqlDbType.VarBinary, file.Length).Value = file;
VARBINARY(MAX)- notVARCHAR(MAX)(which is string-based - NOT binary!)