2

I'm having issues getting a file from a FILESTREAM varbinary(max) column.

I added it to a table using this:

ALTER TABLE [dbo].News ADD RowGuidColId 
     UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE DEFAULT (NewId())
GO

ALTER TABLE News ADD NewsPngFile varbinary(max) FILESTREAM NULL
GO

I insert the picture using entity framework. But when I try to query, the GET_FILESTREAM_TRANSACTION_CONTEXT() returns NULL. What might be wrong?

enter image description here

Arulkumar
  • 12,966
  • 14
  • 47
  • 68
Lasse Edsvik
  • 9,070
  • 16
  • 73
  • 109

1 Answers1

3

Have you already committed the transaction? To use this you need to explicity open a transaction, obtain the transaction context with the call to GET_FILESTREAM_TRANSACTION_CONTEXT() and then commit. GET_FILESTREAM_TRANSACTION_CONTEXT() will return NULL if the transaction has not been started, or has been canceled or committed.

There's a bit of documentation with an example available here:

GET_FILESTREAM_TRANSACTION_CONTEXT (Transact-SQL)

steoleary
  • 8,968
  • 2
  • 33
  • 47