SQL Sever 2005 Image saving and retrieving

  • Hi,

    I have a problem in the Image storing and retrieving at SQL Server 2005, my code is:

    for storing:

    Image

    tempImg;

    tempImg = (

    Image) picPhotograph.Image;

    tempImg.Save(memBuffer, System.Drawing.Imaging.

    ImageFormat.Bmp);

    bfrBuffer =

    new byte[memBuffer.Length];

    memBuffer.Read(bfrBuffer, 0, (

    int)memBuffer.Length);

    I am sending bfrBuffer using stored procedure to SQL server 2005, by when executing for storage, getting error as "Operand type clash: image is incompatible with varchar", I am using DBtype.binary to assign bfrBuffer in the stored procedure parameter, I think here is the problem.

    for retriving: 

    Image tempImg;

    memBuffer.Write(bytEmployee, 0, bytEmployee.Length);

    tempImg =

    Image.FromStream(memBuffer);

    picPhotograph.Image = tempImg;

    Here I am getting "parameter not valid" in the "tempImg = Image.FromStream(memBuffer);".

    Can anybody help me.

    Regards,

    Nelson.

  • This was removed by the editor as SPAM

  • Hi Nelson..

    What datatype is expected by the stored procedure?

    The error message suggests that the stored procedure is coded with an nvarchar parameter.  Changing it to varbinary(max) should resolve this issue.

    Hope this helps..


    Take care..

    - Ward Pond
    blogs.technet.com/wardpond

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply