Skip to content
Advertisement

coverting byte array from database to video file

my name is omer and im a student. my project is a website, in the websitye there is an ption that the user will upload a file. the websiteput it on the database and than show it but some why all i get from database is “System.Byte[]” insed of getting the video’s bytes. idk know what is wrong in my code. help pls.

My library “my video helper” code:

my c sharp code:

my library “MyAdoHelper” code:

Advertisement

Answer

Your insert statement:

will end up as a SQL statement like this:

Because when you concat your byte array like this:

You get this:

SOLUTION:

You should use parameterized queries, both for the sake of security and be able to write a byte[] into the database.

Add this method to your MyAdoHelper class. To be consistent, I am naming the variables as you did, which normally would not be my choice of naming.

Then, insert the video using the following code block:

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