Insert or Save file into SQL Server Database Table with C# Examplesand VB.Net Examples

  • Thread starter Thread starter Jayesh Sorathia
  • Start date Start date
There is a need in application to upload a file and store into SQL Server Database table.
You can do this very simple way.
File is stored in sql server as binary data. You need to set "varbinary" data type of the column in which you want to store file. You need to take "varbinary(MAX)" data type.

Three suggestions:
1) Use the using statement to ensure connection gets closed
2) Add parameters and values separate and define type for the parameters
when adding them
3) Drop the Hungarian style obj prefix is not recommended for .NET (with
the exception of the I prefix)

Arne
 
Three suggestions:

1) Use the using statement to ensure connection gets closed

2) Add parameters and values separate and define type for the parameters

when adding them

3) Drop the Hungarian style obj prefix is not recommended for .NET (with

the exception of the I prefix)



Arne

Hi,
Thanks for you valuable suggestion.
 
Back
Top