How To Display/Pass TimeStamp Value from/to SQL Server (170380)
The information in this article applies to:
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q170380 SUMMARY
TimeStamp is a SQL Server data type that is automatically updated every
time a row is inserted or updated. Values in TimeStamp columns are not
datetime data; they are, by default, defined as binary(8) varbinary(8),
indicating the sequence of Microsoft SQL Server activity on the row. A
table can have only one TimeStamp column. The TimeStamp data type is simply
a monotonically-increasing counter whose values will always be unique
within a database.
In Visual Basic, by opening an RDO cursor and setting the concurrency
control options as the Locktype argument of the OpenResultset method, RDO
will handle the locking automatically. However, there are situations in
which you might prefer to perform all operations against the database with
stored procedures at the server side. If this is the case, a TimeStamp
value could be used to check if the row has been modified in between the
time that it was first selected and the time that the update is posted.
This article provides the Visual Basic code that converts and displays the
value in a string-type format to retrieve a TimeStamp column from a SQL
Server table. Additionally, for comparison, the value is passed back to a
stored procedure, which does the update based on the a WHERE clause
evaluation of true. An error is raised if the concurrency check fails.
Keep in mind that TimeStamps were intended for use by SQL Server internally
and, as such, the format is subject to change without notice.
Modification Type: | Minor | Last Reviewed: | 7/1/2004 |
---|
Keywords: | kbhowto KB170380 |
---|
|