C # insert Timestamp data in Oracle

Source: Internet
Author: User
Tags time in milliseconds

C # insert Timestamp data in Oracle

In project development, it is required to save the time in milliseconds. Although the DateTime type in C # has the Millsecond attribute, the data in milliseconds cannot be saved when the Timestamp type Oracle data column is inserted.

The following is my development environment:

  • Operating System: Windows
  • Development tools: Visual Studio 2010
  • Development language: C #
  • Database: Oracle 10.2.0.4

Similar problems were encountered in previous projects. At that time, they were solved by saving strings. Specifically, define the field type as String in the Entity class of the program, define the corresponding column as Varchar2 () in the database, and call DateTime. now. toString ("yyyy-MM-dd HH: mm: ss. fff ") statement to save the millisecond precision time. In this way, the function can be implemented, but it is difficult to switch between the database and the database reading. I want to find a permanent solution.

After communicating with the brothers, I thought that since DataTime was saved for several milliseconds, but it was lost after it was saved, it is very likely that it was stored with Microsoft's Oracle Driver (System. data. oracle client), you can try to use the official Oracle Driver (Oracle. managedDataAccess. client ). Sure enough, after the driver is changed, the data is saved in milliseconds and the problem is solved successfully.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.