Saving Files to SqlServer using SaveChanges method in Visual Basic

I need to save a file in sqlserver database using Visual Basic. Can someone help. I have tried to use a savechanges method of dbcontext class, it is throwing an error.

Many thanks


For anyone to be able to help you, you need to post the relevant code and any information about the error. Screencaps are not helpful.

dbContext.SaveChanges() is merely attempting to write whatever changes you have made to the database. So the problem is most likely NOT in SaveChanges(), but in how you attempted to write the file to the database. That said, SaveChanges() may fail because you initialized the context incorrectly, etc.

And when you say “save file”, I’m assuming you are trying to 1) open a file on the file system; 2) read the file’s contents; 3) save the file contents to a row in the database.  Binary file? Text file?