Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image data type SQL Server 2008 C# data type

Tags:

c#

sql-server

I created a data table

CREATE TABLE [ProductImages]
(
[ProductImageID] [int] IDENTITY(1,1) NOT NULL,
[ProductImage] [image] NOT NULL
 CONSTRAINT [PK_ProductImages] PRIMARY KEY CLUSTERED
 (
   [ProductImageID] ASC
 ) 
)

I'm trying to write ProductImages class in C#

public class ProductImages
{
    private int productImageID;

    public int ProductImageID
    {
        get { return productImageID; }
        set { productImageID = value; }
    }

 // I need to declare property for ProductImage???

}

How do i declare property for ProductImage ?

like image 832
user1135534 Avatar asked Feb 14 '12 23:02

user1135534


People also ask

What datatype is used for image in SQL Server?

The IMAGE data type in SQL Server has been used to store the image files. Recently, Microsoft began suggesting using VARBINARY(MAX) instead of IMAGE for storing a large amount of data in a single column since IMAGE will be retired in a future version of MS SQL Server.

What is the data type for image in C#?

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.

What data type is an image?

An image is a composite data type. An image file is typically a binary format file.

Can we store image in SQL database?

We can't store an image directly into the database. For this we have two solutions: To store the location of the image in the database. Converting the image into binary data and insert that binary data into database and convert that back to image while retrieving the records.


1 Answers

public byte[] ProductImage { get; set;} 

Would work... Images are just binary files and you marshal them between SQL Server and your application as the byte[] data type.

like image 59
NotMe Avatar answered Oct 06 '22 19:10

NotMe