SQL 2005 Timestamp comparing in C# using SafeDataReader

SQL 2005 Timestamp comparing in C# using SafeDataReader

Old forum URL: forums.lhotka.net/forums/t/5141.aspx


DazedAndConfused posted on Wednesday, July 23, 2008

I have a time stamp on a SQL server table, which is set to a value of 0x00000000117A33F9. I am unable to extract this using the SafeDataReader, and it always gets returns as an empty byte array.

I have tried using GetBytes and GetValue and converting to a byte array, but can't seem to make the value change, based on the return result of the stored procedure.

How am I meant to do this in C#?

dcleven replied on Wednesday, July 23, 2008

This works for me.

//timestamp declared                                    

private byte[] m_timestamp = new byte [ 8 ];

// timestamp read from SafeDataReader

dr.GetBytes("Timestamp", 0, m_timestamp, 0, 8);

Copyright (c) Marimer LLC