0

I'm trying to insert multiple documents at once. Database used is SQL 2008 My table has Image column type.

Now I am forming a datatable in c#, which has around 8-10 columns. One of the column is Byte[] type, where the file content is being saved. I am passing this datatable to the service where SProc is invoked.

In SProc , there is only 1 inout param, i.e. table type SessionDetails. Here the other columns are mapped according to the columns of datatable. The filecontent is being saved in FileContent column, which is of type Varbinary(max).

INSERT works correctly, but when I am trying to read the stored data, it is not able to open the uploaded doc/image/pdf .

I'm not sure where the issue is. In SP at no place I am using cast/convert for this variable At c# or database level :(

CREATE TYPE [dbo].[SessionDetails] AS TABLE(
    [PID] [varchar](50) NULL,
    [PString] [varchar](max) NULL,
    [Objecttype] [int] NULL,
    [FileName] [varchar](500) NULL,
 [FileContent] varbinary(max) ,
    [FileType] [varchar](50) NULL,
    [ID] [int] NULL
)

Table details

attachment table - 
Column name :iFile  
Columntype: image
jarlh
  • 42,561
  • 8
  • 45
  • 63
Xander Kage
  • 161
  • 16
  • How are you reading the stored data? If it's by code can you post the snippet here – Izzy Jun 09 '15 at 08:05
  • [You need to convert `varbinary` to a `byte[]` array](http://stackoverflow.com/questions/7724550/retrieve-varbinarymax-from-sql-server-to-byte-in-c-sharp) – Kaf Jun 09 '15 at 08:06
  • I cant change the way the file is read . Neither do I have the code of the application which reads the file once the file is saved in database. I also cannot change the table column type. So whatever change I need to do , it has to be while saving the file in the database. Pls help :( – Xander Kage Jun 09 '15 at 08:53

0 Answers0