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.