1
Follows code:
var bytes = ConvertTo.Bytes(file);
int num = ctx.Database.ExecuteSqlCommand(
$"UPDATE dbo.Table" +
$"SET Video = '{bytes}' " +
$"WHERE id = {Id} ");
Follow code to convert:
public static byte[] Bytes(HttpPostedFileBase file)
{
var length = file.InputStream.Length;
byte[] fileData = null;
using (var binaryReader = new BinaryReader(file.InputStream))
{
fileData = binaryReader.ReadBytes(file.ContentLength);
}
return fileData;
}
I get error:
Implicit conversion of data type varchar to varbinary(max) is not permitted. Use the CONVERT function to execute this query.
Some solution?
What type of column
Video
at the bank?– Jéf Bueno
@LINQ, varbinary(max)
– Matheus Miranda