SQLTimeStamp and Byte[]

I am very confused with what I am to do with a SQLTimeStamp(stamp is in binary). In my web application, when a user selects a record to update it, a SQLTimeStamp is sent upon retrieval. When I get the SQLTimeStamp from the database, it is returned as an object. That object contains a byte[] array to represent the binary SQLTimeStamp.

What I have to do is convert this object to a byte[] array. How do I do that Any help would be appreciated. Thanks.



Answer this question

SQLTimeStamp and Byte[]

  • Thomas K Knudsen

    Hi

    Just to understand your scenario correctly, can you tell me which API you are using to get the SQLTimeStamp object.

    Thanks

    With regards
    Ashwin Raja


  • Alexey A. Vasilyev

    Hi;

    It's 8 bytes so I convert it into a long as follows:

    public static long GetTimestamp(IDataRecord reader, int ordinal)
    {
    byte[] data = new byte[ 8 ];
    reader.GetBytes(ordinal, 0, data, 0, 8);
    Int64 rtn = 0;
    for (int ind = 0; ind < 8; ind++)
    {
    rtn <<= 8;
    rtn |= data[ind];
    }
    return rtn;
    }



  • SQLTimeStamp and Byte[]