开发者

c# Database timestamp [closed]

开发者 https://www.devze.com 2023-03-02 21:23 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_Go百科 Closed 11 years ago.

I would like to know when the database was timestamped from c# code.. Is this possible and if so, how can I do it?


It sounds like you may want a column in your table which is automatically updated by the database itself on update (e.g. with a trigger). Personally I prefer to let the database perform this task rather than the client, as it means you can get it right in one place and be certain that nothing else can modify the data (even with SQL entered manually) without the timestamp being updated.

Of course, that's assuming you're talking about a row-level timestamp recording the last change. The question isn't clear about that.


you can do as below and store in the database

private String GetTimestamp(DateTime value) {
    return value.ToString("yyyyMMddHHmmssffff");
}

This will give you a string like 201105211035131468

0

精彩评论

暂无评论...
验证码 换一张
取 消