Hi,

I have a filestream enabled DB and a table to store the files. Until now i used to get the path of the file that has to be saved to DB. But due to some changes this was changed and now i get a byte array. my question here is
1. Can this be done? (if yes, then how? Note: the present implementation is a stored procedure that will get the path)
2. Does this implementation have any advantages - performance wise?

I have a little bit more information at this point of time. I am using edmx and in the classes that are generated the type of the varbinary(max) column of the table is byte[]. So i tried to add the byte raay to this bute array and save the record.. but now the id field (a guid column) of the table is always same.

following is the table script:

CREATE TABLE [dbo].[BinaryFileSource](
    [BinaryFileSourceID] UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL,
    [FileObject] varbinary(max) FILESTREAM NULL,
    CONSTRAINT UQ_BinaryFileSource_FileID UNIQUE (BinaryFileSourceID)
)
GO
ALTER TABLE [dbo].[BinaryFileSource]
    ADD CONSTRAINT DF_BinaryFileSource_BinaryFileSourceID DEFAULT NEWID() FOR BinaryFileSourceID
GO
ALTER TABLE [dbo].[BinaryFileSource]
    ADD CONSTRAINT PK_BinaryFileSource_BinaryFileSourceID PRIMARY KEY (BinaryFileSourceID)
GO

This problem is solved.. the GUID of 0000...... is assigned default by the entity framework. SO the default part of the table was never being used.. Now i have send a GUID from code-side.. Works Fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.