You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by toast21 <we...@uk.bnpparibas.com> on 2007/12/11 11:16:13 UTC

persisting image in SQL Server

Hi Everyone,

I'm using the iBatis data mapper 1.6.1 for my c# (VS2005) ASP .NET project.. 
I'm
trying to persist an image and even though it all runs fine, the image does
not seem to be stored in the database.    We're using an SQL Server 2000
back end and the column in question is an "image" type. I've tried looking
at the FAQ and
doing a search on the net... there's a lot of resources saying that it CAN
be done but unfortunately nothing on HOW to do it.

In my, class, i've defined the image as :
        private Byte[] distributionChart;
with the standard properties:
        public Byte[] DistributionChart
        {
            get { return distributionChart; }
            set { distributionChart = value; }
        }

My parameter map uses :
    <parameter property="DistributionChart" column="distributionChart"
dbType="image" />

And my stored procedure:
CREATE PROCEDURE QuantonomicsProvider_UpdateEvent
@eventId int,
@distributionChart image
AS
UPDATE      AnnouncementEvent
SET         DistributionChart = distributionChart
WHERE Id = @eventId
GO

I've stepped through my code and can confirm that there's data in the
object and in the "distributionChart" property before i'm storing it.  The
update works without throwing an exception, but there's nothing in the
database.

Does anyone know what i'm doing wrong?  Thanks

Toast
-- 
View this message in context: http://www.nabble.com/persisting-image-in-SQL-Server-tp14271111p14271111.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


Re: persisting image in SQL Server

Posted by toast21 <we...@uk.bnpparibas.com>.
Hi Christopher,

umm yep actually i figured it out a little while ago and felt really really
silly lol.

Thanks for the help!

Christopher DeGuise wrote:
> 
> It appears you are setting the column to itself.
> 
> Instead of:
> SET         DistributionChart = distributionChart
> 
> Try
> 
> SET         DistributionChart = @distributionChart
> 
> Hope that helps.
> 
> Chris
> 
> On 12/11/07, toast21 <we...@uk.bnpparibas.com> wrote:
>>
>>
>> Hi Everyone,
>>
>> I'm using the iBatis data mapper 1.6.1 for my c# (VS2005) ASP .NET
>> project..
>> I'm
>> trying to persist an image and even though it all runs fine, the image
>> does
>> not seem to be stored in the database.    We're using an SQL Server 2000
>> back end and the column in question is an "image" type. I've tried
>> looking
>> at the FAQ and
>> doing a search on the net... there's a lot of resources saying that it
>> CAN
>> be done but unfortunately nothing on HOW to do it.
>>
>> In my, class, i've defined the image as :
>>         private Byte[] distributionChart;
>> with the standard properties:
>>         public Byte[] DistributionChart
>>         {
>>             get { return distributionChart; }
>>             set { distributionChart = value; }
>>         }
>>
>> My parameter map uses :
>>     <parameter property="DistributionChart" column="distributionChart"
>> dbType="image" />
>>
>> And my stored procedure:
>> CREATE PROCEDURE QuantonomicsProvider_UpdateEvent
>> @eventId int,
>> @distributionChart image
>> AS
>> UPDATE      AnnouncementEvent
>> SET         DistributionChart = distributionChart
>> WHERE Id = @eventId
>> GO
>>
>> I've stepped through my code and can confirm that there's data in the
>> object and in the "distributionChart" property before i'm storing it. 
>> The
>> update works without throwing an exception, but there's nothing in the
>> database.
>>
>> Does anyone know what i'm doing wrong?  Thanks
>>
>> Toast
>> --
>> View this message in context:
>> http://www.nabble.com/persisting-image-in-SQL-Server-tp14271111p14271111.html
>> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/persisting-image-in-SQL-Server-tp14271111p14275884.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


Re: persisting image in SQL Server

Posted by Christopher DeGuise <ch...@be-pragmatic.com>.
It appears you are setting the column to itself.

Instead of:
SET         DistributionChart = distributionChart

Try

SET         DistributionChart = @distributionChart

Hope that helps.

Chris

On 12/11/07, toast21 <we...@uk.bnpparibas.com> wrote:
>
>
> Hi Everyone,
>
> I'm using the iBatis data mapper 1.6.1 for my c# (VS2005) ASP .NET
> project..
> I'm
> trying to persist an image and even though it all runs fine, the image
> does
> not seem to be stored in the database.    We're using an SQL Server 2000
> back end and the column in question is an "image" type. I've tried looking
> at the FAQ and
> doing a search on the net... there's a lot of resources saying that it CAN
> be done but unfortunately nothing on HOW to do it.
>
> In my, class, i've defined the image as :
>         private Byte[] distributionChart;
> with the standard properties:
>         public Byte[] DistributionChart
>         {
>             get { return distributionChart; }
>             set { distributionChart = value; }
>         }
>
> My parameter map uses :
>     <parameter property="DistributionChart" column="distributionChart"
> dbType="image" />
>
> And my stored procedure:
> CREATE PROCEDURE QuantonomicsProvider_UpdateEvent
> @eventId int,
> @distributionChart image
> AS
> UPDATE      AnnouncementEvent
> SET         DistributionChart = distributionChart
> WHERE Id = @eventId
> GO
>
> I've stepped through my code and can confirm that there's data in the
> object and in the "distributionChart" property before i'm storing it.  The
> update works without throwing an exception, but there's nothing in the
> database.
>
> Does anyone know what i'm doing wrong?  Thanks
>
> Toast
> --
> View this message in context:
> http://www.nabble.com/persisting-image-in-SQL-Server-tp14271111p14271111.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>