Reputation:
I am working on ado.net entity model and I want to insert data into sql table. SQL table structure is shown below.
ID int,
Name varchar(20),
EventTime Timestamp
I am trying to insert data into SQL Table using entitymodel but data are not inserted in the table.
My passing arguments are (1,"Test")
it's not working.
I figured out that when I pass (1, "test", new Datetime())
then it works.
Can anyone let me know reason for that?
I understand that Timestamps value are automatically inserted by SQL server.
Upvotes: 1
Views: 1203
Reputation: 11916
The "timestamp" data type gives you a binary value that automatically gets updated every time your field changes, but it won't give you a nice date/time value.
Update: as per MSDN: timestamp Is a data type that exposes automatically generated, unique binary numbers within a database. timestamp is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The timestamp data type is just an incrementing number and does not preserve a date or a time.
To record a datetime when the record has been inserted, use a datetime data type. You might add a column of type datetime to your table and set getDAte() to generate the datetime.
Upvotes: 1