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 ?
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.
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.
An image is a composite data type. An image file is typically a binary format file.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With