net code and I am facing this issue when I am trying to insert string in Binary format.
I Have binary format of image in decal.DecalLogoFileName and decal.DecalLogoFileName is define a string so when I am trying as
cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.Binary)).Value=decal.DecalLogoFileName;
decal.DecalLogoFileName="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExIWFhUXGB8aGBcYGR0ZHxobGhoXHRcYGBkaHyghHRolHRcXIjEhJSkrLi4uGB8zODMtNygtLisBCgoKDg0OGhAQGy0lHyUtLS0tLS0tLS0tLS0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAEBQIDBgABB//EAEgQAAIBAgQDBQQHBQYDCAMAAAECEQADBBIhMQVBUQYTImFxMoGRoSNCUrHB0fAUcpLS4QczU2KCshVUc0Njg5OiwuLxFiRk/8QAGQEAAwEBAQAAAAAAAAAAAAAAAQIDAAQF/8QALBEAAgICAgECBQQCAwAAAAAAAAECERIhAzFBE2EiMlFxgUKhsdEEkSMzUv/aAAwDAQACEQMRAD8A"
I am string value in decal as
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#DecalLogo').attr('src', e.target.result);
$('#hdImageName').val(e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
here hdImageName value is store in decal.DecalLogoFileName
I had also tried
cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.Binary)).Value=Convert.toByte(decal.DecalLogoFileName);
But Conversion issue is coming.
The column datatype of DecalLogoFileName is set as varbinary(MAX)