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

A

Arne Vajhøj

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
 
J

Jayesh Sorathia

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top