How to insert image in a database
The data provider is a set of components that include the Connection, Command, DataReader, and DataAdapter Objects. A data type is an attribute that specifies the type of data that the object can hold. Image is a Datatype in SQL Server that stores variable length binary data from 0 through 2A31-1 (2,147,483,647) bytes. The following C# program shows how to insert an Image in SQL Server.
The following sql script help you to create a table with Image Datatype column.
CREATE TABLE [dbo].[imgtable]( [id] [int] NULL, [img] [image] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
The above script will create a table named as imgtable and define two columns , first column is id ,an integer datatype and second column is image, an image(img) datatype.
The following C# source code read the image from phisical path D:\picfile.jpg and stores it to a byte array and then insert it into database.
- What is C# ADO.NET Dataset
- C# Datset with Sql Server Data Provider
- C# Datset with OLEDB Data Provider
- Find Tables in a Dataset - Sql Server
- Find Tables in a Dataset - OLEDB
- How to Dataset rows count - Sql Server
- How to Dataset rows count - OLEDB
- How to find Column Definition SqlServer
- How to find Column Definition OLEDB
- How to Dyanamic Dataset in C#
- C# Dataset with multiple tables - Sql Server
- C# Dataset with multiple tables - OLEDB
- C# Dataset table relations
- C# Dataset merge tables - Sql Server
- C# Dataset merge tables - OLEDB
- Bind a dataset to a combo box in C#, bind enum to combobox , bind dictionary to combobox
- How to find tables in a Database in C#