Getting the text encoded value of a jpg file...

Discussion in 'ASP .Net' started by Charlie@CBFC, Feb 8, 2007.

  1. Charlie@CBFC

    Charlie@CBFC Guest

    Hi:

    I want to set a default value of a varbinary(max) column in SQL Server. The
    reason is my application databinds to a varbinary(max) column to display
    pictures, and if there is no picture when record is created, I would like it
    to default to a common picture. To do this, I will need text encoded
    equivalent of binary file so I can paste it in as a column default. How do
    I do this?

    Thanks,
    Charlie
     
    Charlie@CBFC, Feb 8, 2007
    #1
    1. Advertising

  2. Charlie@CBFC

    bruce barker Guest

    do a hex dump of the image. then use this syntax:

    insert table (@id, 0xfffffffffff)




    Charlie@CBFC wrote:
    > Hi:
    >
    > I want to set a default value of a varbinary(max) column in SQL Server. The
    > reason is my application databinds to a varbinary(max) column to display
    > pictures, and if there is no picture when record is created, I would like it
    > to default to a common picture. To do this, I will need text encoded
    > equivalent of binary file so I can paste it in as a column default. How do
    > I do this?
    >
    > Thanks,
    > Charlie
    >
    >
     
    bruce barker, Feb 8, 2007
    #2
    1. Advertising

  3. Charlie@CBFC

    Guest

    On Feb 8, 7:47 am, "Charlie@CBFC" <> wrote:
    > Hi:
    >
    > I want to set a default value of a varbinary(max) column in SQL Server. The
    > reason is my application databinds to a varbinary(max) column to display
    > pictures, and if there is no picture when record is created, I would like it
    > to default to a common picture. To do this, I will need text encoded
    > equivalent of binary file so I can paste it in as a column default. How do
    > I do this?
    >
    > Thanks,
    > Charlie


    Why don't you upload the default file to your database and have it as
    ID of 0. Then in control the insert of the default image in your SP,
    if the jpg is dbnull then do an insert of the default file you have
    you in your database.

    if( @filedata is null)

    select @imagedata=data from files where id=0


    insert into files(imagedata) values(@imagedata)



    - Manit
    http://www.acriticsreview.com
     
    , Feb 9, 2007
    #3
  4. Charlie@CBFC

    Charlie@CBFC Guest

    Thanks guys. I downloaded a hex editor to get at the code.

    Used it in SP. Works great.

    "bruce barker" <> wrote in message
    news:%...
    > do a hex dump of the image. then use this syntax:
    >
    > insert table (@id, 0xfffffffffff)
    >
    >
    >
    >
    > Charlie@CBFC wrote:
    >> Hi:
    >>
    >> I want to set a default value of a varbinary(max) column in SQL Server.
    >> The reason is my application databinds to a varbinary(max) column to
    >> display pictures, and if there is no picture when record is created, I
    >> would like it to default to a common picture. To do this, I will need
    >> text encoded equivalent of binary file so I can paste it in as a column
    >> default. How do I do this?
    >>
    >> Thanks,
    >> Charlie
     
    Charlie@CBFC, Feb 9, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roland
    Replies:
    0
    Views:
    1,096
    Roland
    May 12, 2004
  2. Matthias
    Replies:
    5
    Views:
    463
    Whitecrest
    Jun 1, 2004
  3. Yannick

    ASP changes Big JPG -> Small JPG

    Yannick, Feb 2, 2004, in forum: ASP General
    Replies:
    6
    Views:
    171
    Tim Williams
    Feb 3, 2004
  4. Vilmar Brazão de Oliveira
    Replies:
    14
    Views:
    379
    Aaron Bertrand [MVP]
    Mar 5, 2004
  5. Replies:
    3
    Views:
    280
    Andy Dingley
    Sep 27, 2006
Loading...

Share This Page