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

Discussion in 'ASP .Net' started by Guest, Jul 6, 2006.

  1. Guest

    Guest Guest

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

    Anyone can give me a help?

    Thank you.

    Guest, Jul 6, 2006
    1. Advertisements

  2. Guest

    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++)





    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.
    sloan, Jul 6, 2006
    1. Advertisements

  3. Guest

    Guest Guest

    Do you know any stored function to do it?


    Guest, Jul 6, 2006
  4. Steve C. Orr [MVP, MCSD], Jul 7, 2006
  5. Guest

    sloan Guest

    sloan, Jul 7, 2006
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.