Senator
Senator

Reputation: 39

Compare SQL Timestamp

I use ADO.NET to retrieve a table from sql2k server, where one of the field is timestamp type. I want to compare this field for concurrency checking, but I found that the value returned by ADO.NET is an array of byte. Can I just convert it to say long, or do I need to compare it byte by byte?

Upvotes: 0

Views: 631

Answers (1)

SQLMason
SQLMason

Reputation: 3275

You can ASCIIEncoding.ASCII.GetString(var) to compare / display. I believe var.Equals(var2) will also work or Object.Equals(var1, var2)

If you'd doing an update, it's better to let the CRUD proc do this and return 0 for results affected when you run the proc and handle it there. Opposed to querying for the current timestamp.

Upvotes: 1

Related Questions