How to store/retrieve binary data in/from SQL server DB?

Discussion in 'ASP .Net' started by =?Utf-8?B?ZGF2aWQ=?=, Jul 6, 2006.

  1. I remember that there are functions to do it, but I forgot their names.

    Anyone can give me a help?

    Thank you.

    David
     
    =?Utf-8?B?ZGF2aWQ=?=, Jul 6, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?ZGF2aWQ=?=

    sloan Guest

    IDataReader has a .GetBytes method.

    Something like this:


    object o = dataReader.GetValue (123);

    Console.WriteLine ("");

    byte[] byteCodes = new byte[8];

    long len = dataReader.GetBytes(123, 0, byteCodes, 0, 8);


    Console.Write("Byte codes: ");

    for (int i = 0; i < len; i++)

    {

    Console.Write(byteCodes.ToString("x"));

    }

    }


    That was getting a timestamp value (8 length). You'll need to rework it, if
    the length is unknown.

    123 represents the ordinal position of the select statement.

    Select lastname, firstname from Emp
    lastname ordinal is 0
    firstname ordinal is 1

    I used 123 so it would stand out.



    "david" <> wrote in message
    news:...
    > I remember that there are functions to do it, but I forgot their names.
    >
    > Anyone can give me a help?
    >
    > Thank you.
    >
    > David
     
    sloan, Jul 6, 2006
    #2
    1. Advertising

  3. thanks.
    Do you know any stored function to do it?

    David

    "sloan" wrote:

    >
    > IDataReader has a .GetBytes method.
    >
    > Something like this:
    >
    >
    > object o = dataReader.GetValue (123);
    >
    > Console.WriteLine ("");
    >
    > byte[] byteCodes = new byte[8];
    >
    > long len = dataReader.GetBytes(123, 0, byteCodes, 0, 8);
    >
    >
    > Console.Write("Byte codes: ");
    >
    > for (int i = 0; i < len; i++)
    >
    > {
    >
    > Console.Write(byteCodes.ToString("x"));
    >
    > }
    >
    > }
    >
    >
    > That was getting a timestamp value (8 length). You'll need to rework it, if
    > the length is unknown.
    >
    > 123 represents the ordinal position of the select statement.
    >
    > Select lastname, firstname from Emp
    > lastname ordinal is 0
    > firstname ordinal is 1
    >
    > I used 123 so it would stand out.
    >
    >
    >
    > "david" <> wrote in message
    > news:...
    > > I remember that there are functions to do it, but I forgot their names.
    > >
    > > Anyone can give me a help?
    > >
    > > Thank you.
    > >
    > > David

    >
    >
    >
     
    =?Utf-8?B?ZGF2aWQ=?=, Jul 6, 2006
    #3
  4. Yes, here's an example that allows upload and download of files and binary
    storage of them in SQL Server.
    http://SteveOrr.net/articles/EasyUploads.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "david" <> wrote in message
    news:...
    >I remember that there are functions to do it, but I forgot their names.
    >
    > Anyone can give me a help?
    >
    > Thank you.
    >
    > David
     
    Steve C. Orr [MVP, MCSD], Jul 7, 2006
    #4
  5. =?Utf-8?B?ZGF2aWQ=?=

    sloan Guest

    (another) nice write up Steve.



    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:O8dVI$...
    > Yes, here's an example that allows upload and download of files and binary
    > storage of them in SQL Server.
    > http://SteveOrr.net/articles/EasyUploads.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    >
    > "david" <> wrote in message
    > news:...
    > >I remember that there are functions to do it, but I forgot their names.
    > >
    > > Anyone can give me a help?
    > >
    > > Thank you.
    > >
    > > David

    >
    >
     
    sloan, Jul 7, 2006
    #5
    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. angus
    Replies:
    2
    Views:
    484
    Elliot M. Rodriguez, MCSD
    May 20, 2004
  2. Universal
    Replies:
    1
    Views:
    600
    Lionel B
    Apr 8, 2005
  3. Universal
    Replies:
    0
    Views:
    458
    Universal
    Apr 8, 2005
  4. Karl
    Replies:
    3
    Views:
    5,239
    saloniSona
    Oct 7, 2009
  5. =?Utf-8?B?c2NvdHRybQ==?=

    retrieve binary data from database and display in browser

    =?Utf-8?B?c2NvdHRybQ==?=, Mar 23, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    719
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 23, 2007
Loading...

Share This Page