Skip to content
Advertisement

reading or converting to file -byte[] array wrong

my name Is Omer and I’m a student. In my project I had to upload videos to database and also read them from the database. I’m using OLE object field to store byte[]array. But IDK why I Cant convert it back to file. I don’t know if my problem is in the inserting from the database or in the selecting. my Inserting code:

SaveFileInFoder:

UploadVideo:

the selecting part:

Advertisement

Answer

For the sake of simplicity I am saving file data as VarBinary(MAX) in the table. For big files ( bigger than ~1MB) you probably will use BLOB or FileStream.

File Stream Storage SQL 2008

Simple Get File method : (omitting validation and try ,catch)

Save Data in DB (try avoiding using SQL reserved word for column names, like ‘file’)

Get Data from DB and save as MP4 file

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement