Article ID: 196590 - Last Review: March 2, 2005 - Revision: 1.2 How To Pass a Timestamp to/from a SQL Stored Procedure w/ ADOThis article was previously published under Q196590 On This PageSUMMARY
A SQL Server timestamp column automatically updates every time a row is
inserted or updated. Despite the name, a SQL Server timestamp column is not
based on the system time and does not contain a date or time value.
Instead, the timestamp column is an array of binary values. The ActiveX
Data Objects (ADO) adDBTimeStamp datatype is used for dates. Since a SQL
Server timestamp is neither a date nor a time, do not use adDBTimeStamp to
retrieve or pass SQL Server timestamp values. Use adVarBinary with a size
of eight (8).
MORE INFORMATION
You can retrieve a row using a timestamp as criteria. The timestamp must be
stored in a Variant variable. Use an ADO Command object. Then you can
explicitly pass the timestamp as an ADO parameter of type adVarBinary and
size eight (8).
Although you may retrieve records based on a timestamp value, never change the value of a SQL Server timestamp. Allow SQL Server to update timestamps automatically. The following sample code creates a test table. The test table has a datetime column and a timestamp column. The Visual Basic code in Command1 retrieves a record based on a datetime value. The timestamp is then stored in a Variant variable. In Command2, the timestamp retrieved in Command1 is used to retrieve the same record. The ADO datatype for a timestamp is adVarBinary with a size of eight (8). Steps to Accomplish TaskCreate the Table and Insert Records
Create the Visual Basic Application
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base, which discusses timestamp values and Remote Data
Objects (RDO):
170380
(http://support.microsoft.com/kb/170380/EN-US/
)
How To Display/Pass TimeStamp Value from/to SQL Server
For additional information, please see the following article in the
Microsoft Knowledge Base, which enumerates the datatype constants used when
passing parameters and their string equivalents:
181199
(http://support.microsoft.com/kb/181199/EN-US/
)
How To Determine How ADO Will Bind Parameters
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Margery Simms, Microsoft Corporation.APPLIES TO
| Article Translations
|

Back to the top
