"Next" <ae******************@cafsmail.no*jg^_junk..com> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl...
//I have tried byte and byte[].
byte[] _tempTS;
while (dr.Read())
{
.
.
.
//Tried several conversions here. This doesn't work because
//it doesn't return a byte[]
_tempTS = Convert.ToByte(dr["timestamp"].ToString());
//Can't compare strings; Can't compare byte[]. How should
//I make this comparison
if( _tempTS > _timeStamp)
{
_timeStamp = _tempTS;
}
Try this :
byte[] _tempTS; // stick with a byte array.
....
_tempTS = (byte[]) dr["timestamp"];
// timestamp columns should be of type : byte[], so the cast should work.
To make the comparison, you'll have to compare the byte array one byte
at a time. If you want a human readable string representation of the
byte array, you could use a routine like this :
private string ConvertBytesToString(byte[] b)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("0x");
for (int i = 0; i < b.Length; i++)
{
sb.Append(b[i].ToString("X2"));
}
return sb.ToString();
}
i.e.
string str = ConvertBytesToString(_tempTS);
If this doesn't help, try the dotnet adonet newsgroup -
they'll probably be of more help.
HTH,
Stephen