This is a migrated thread and some comments may be shown as answers.

Save image with procedure.

4 Answers 84 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gadonski
Top achievements
Rank 1
Gadonski asked on 24 Sep 2010, 01:02 PM
I am using Telerik's ORM...

This stored procedure does not save the data, it seems to be a problem with the VARBINARY. I am passing a byte[] to it, but then it doesn't work. If I send this parameter as NULL it works.

"QP_AddCommunity ?, ?, ?, ?, ?, ?", "VARCHAR Name, VARCHAR Description, VARBINARY Picture, INTEGER Owner, INTEGER Venue, INTEGER ID"

Here is my procedure, which works just fine executing directly on SQLServer.

USE [redimob]
GO
 
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[QP_AddCommunity]
    @Name VARCHAR(120),
    @Description VARCHAR(MAX),
    @Picture VARBINARY(MAX),
    @Owner INTEGER,
    @Venue INTEGER,
    @ID INTEGER
      
AS
BEGIN
    SET NOCOUNT ON;
  
    IF(SELECT COUNT(*) FROM QT_Community WHERE ID = @ID) = 0
        INSERT INTO QT_Community(Name, [Description], Picture, [Owner], Venue) VALUES(@Name, @Description, @Picture, @Owner, @Venue);
          
    ELSE
        UPDATE QT_Community SET Name = @Name, [Description] = @Description, Picture = @Picture, [Owner] = @Owner, Venue = @Venue WHERE ID = @ID;
          
    SELECT * FROM QT_Community WHERE ID = @@IDENTITY;
          
      
END


What am I doing wrong? Isn't VARBINARY a byte[] ?

4 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 24 Sep 2010, 02:15 PM
Hi André,

Have you tried using the IMAGE sql type instead of VARBINARY?

I have used both the IMAGE sql type and the VARBINARY(MAX) and they worked like a charm.

Maybe you should change the parameter when you call the SP from VARBINARY to VARBINARY(MAX)

Regards

Henrik
0
Gadonski
Top achievements
Rank 1
answered on 24 Sep 2010, 06:02 PM
Hi Henrik,

I can't undestand what you are trying to say. Could you elaborate more on your answer?
0
IT-Als
Top achievements
Rank 1
answered on 25 Sep 2010, 08:29 AM
Hi André,

Instead of using VARBINARY to hold the binary content, use the IMAGE datatype.

I think I remember seeing a post once, that VARBINARY was not supported when doing SP's.

Maybe someone from Telerik can elaborate on this.

Regards

Henrik
0
Ady
Telerik team
answered on 29 Sep 2010, 05:23 PM
Hello Andre,

 As Henrik rightly pointed out there was a bug when dealing with VARBINARY parameters and stored procedures. This has been fixed now and the fix would be available in the next build that we will soon release.

Sorry for the inconvenience caused.

Kind regards,
Ady
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Development (API, general questions)
Asked by
Gadonski
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
Gadonski
Top achievements
Rank 1
Ady
Telerik team
Share this question
or