I would like to insert a binary value into the database without using FileUpload. I searched for tutorials, samples and i saw only codes like:
Dim fs As Stream = FileUpload1.PostedFile.InputStream
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(fs.Length)
But, I have already a file/data in my asp:Image> with the use of a Canvas,
var dataURL = canvas.toDataURL();
which is data:image/png;base64,iVBORw0KGgoAAAANSU...etc.
I am inserting it already in the database by putting it in a textarea
document.getElementById("TextArea1").value = dataURL;
and in my code behind.
Dim sqlComm As New SqlCommand("INSERT INTO patient_data.dbo.tbPatientImage (HospNum,IdNum,DoctorID,TransDate,PatImage,FileType,FileSize) VALUES (@HospNum,@IDNum,@DoctorID,getdate(),@PatImage,'image/jpg','0')", sqlConn)
Dim photoParam As New SqlParameter("@PatImage", SqlDbType.VarChar)
sqlcomm.photoParam.Value = TextArea1.Value
sqlcomm.Parameters.Add(photoParam)
sqlcomm.ExecuteNonQuery()
Yeah it is inserting but when i try to retrieve it on the database, it does not show anything.
Some files that were inserted by the use of Fileupload were retrieved and displayed correctly, but the inserted data:image/png;base64,iVBORw0KGgoAAAANSU...etc. doesn't work. What should i do? is there an easier/better way?