Re: Timestamp Value - please help
From: DalePres (nospam_at_nomail.com)
Date: 05/02/04
- Next message: Ashton Hobbs: "Re: ADO.NET Not Returning Error"
- Previous message: JJ: "Active record in a datagrid"
- In reply to: Richard: "Timestamp Value - please help"
- Next in thread: Richard: "Re: Timestamp Value - please help"
- Reply: Richard: "Re: Timestamp Value - please help"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 2 May 2004 17:11:53 -0500
A timestamp value isn't really designed to be retrieved or queried against.
It is not even guaranteed to remain the same over time since each time you
change or update a row, the timestamp changes. Rows updated later will
always have a higher timestamp value than rows updated earlier. That's the
only assumption you should make. Timestamps are intended to allow you to
sort based on update time but do not represent actual times.
If you want to record row update/creation times for later retrieval, use a
datetime column with GETDATE() so that all the times are in server time.
Though not guaranteed to give as reliable of a timestamp as a timestamp
column would, in all but the most rare of situations, it would be completely
reliable and/or acceptable.
Dale
"Richard" <anonymous@discussions.microsoft.com> wrote in message
news:88F38A33-E28B-4AAE-9FC2-445F65F6BA2C@microsoft.com...
> I am using a class to store values from a query, but I have found no
documentation to show how to capture the actual value of a timestamp from a
SQL Server 2000 database table using VB.Net. I need to use the timestamp in
the Where clause of an update statement, but the value returned is
"System.Byte[]", not the actual value. Here is some of my code:
>
> 'Assume I've pulled these fields from table (TS is timestamp)
> Select EmpID, FirstName, LastName, TS From Employees
>
> Private mintEmpID As Integer
> Private mstrFN As String
> Private mstrLN As String
> 'I'm using a byte array to store the TS. Is that the right way to do it?
> Private mbytTS(8) As Byte
>
> 'Here's my data.
> With ds.Tables(0).Rows(0)
> mintEmpID = .Item("EmpID")
> mstrFN = .Item("FirstName")
> mstrLN = .Item("LastName")
> mbytTS = .Item("TS")
> End With
>
> When the user changes the data and saves, the update query using the TS in
the Where clause fails because mbytTS reads 'System.Byte[]' instead of the
actual timestamp.
>
> Private sql as String
> sql = "Update Employees Set FirstName='" & mstrFN & "', LastName='" &
mstrLN & "' Where EmpID = " & mintEmpID & " And TS =" & mybtTS
>
> I'm missing the key thing here, which is the actual timestamp value. Can
someone please tell me how to capture the timestamp into a variable, and
reference it correctly in the update query? Thank you in advance for your
help.
>
- Next message: Ashton Hobbs: "Re: ADO.NET Not Returning Error"
- Previous message: JJ: "Active record in a datagrid"
- In reply to: Richard: "Timestamp Value - please help"
- Next in thread: Richard: "Re: Timestamp Value - please help"
- Reply: Richard: "Re: Timestamp Value - please help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|