Displaying SQL Timestamp in a Datagrid

  • Thread starter Nathan Waddington
  • Start date
N

Nathan Waddington

Hello,

When I try to display a SQL Timestamp type in a datagrid I get the
following output: System.Byte[]

Is there any way to show the timestamp that the Timestamp type holds?
Cheers,
Nathan.
 
M

Mary Chipman

The timestamp data type is an automatically generated binary number
which is guaranteed to be unique within the database, nothing more. It
has nothing to do with the datetime data type. It is used mainly where
there are text or image columns so that the server can determine
whether a row has been updated without having to actually load the
text or image. Is there a reason why you feel you need to display this
value? Normally it is used for comparison, where you compare the value
of a fetched timestamp in a dataset row with the value that is
currently in the database.

--Mary
 
N

Nathan Waddington

Hello Mary,

Thanks for the info, I want to display the data as I thought it was
actually a timestamp. I want a timestamp, I'd like to know when the
record was last updated. It seems like I need to build some triggers
in order to set a datetime on insert and update to achieve what I want
then. Although the actual use of Timestamp is intriguing and I will
have to look into it further.

Thanks again,
Nathan.
 
G

Guest

Hi Nathan,

All you have to do to accomplish this is add a date field to the table and
set the default of the field to the GetDate() function. Now every time there
is an insert the date will be populated for you.

I hope this helps.
------------------------------------
 
M

Mary Chipman

If you want to see the actual date and time the data was updated, then
yes, you will need to add a trigger to handle this. If you don't like
the idea of a trigger, an alternative would be to code all of your
update code in parameterized stored procedures where the stored
procedure adds the datetime value as part of the update. You then need
to disallow direct data entry into the table, and code your
application to use only the update stored procedure.

--Mary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top