Oracle.ManagedDataAccess reads DST dates incorrectly

孤者浪人 提交于 2019-12-04 18:02:42

Oracle.ManagedDataAccess is still quite new, so you also get always the "newest" bugs.

There are others ways to define your current session timezone, maybe one of the following works.

  • Usage of OracleGlobalization class:

    this.Connection = new OracleConnection();
    this.Connection.ConnectionString = ...
    this.Connection.Open();
    OracleGlobalization info = this.Connection.GetSessionInfo();
    info.TimeZone = "America/New_York";
    this.Connection.SetSessionInfo(info);
    

    Test this very carefully, my experience with OracleGlobalization is quite bad. Test also this.Connection.OpenWithNewPassword(...);, not only this.Connection.Open();. When I used OpenWithNewPassword my application was crashing without any error (even while debugging in Visual Studio!)

  • Set ORA_SDTZ as Environment variable in your system.

  • Set timezone in your Registry, it is a String Value for HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_{YOUR_ORACLE_HOME_NAME}\ORA_SDTZ, e.g.

    For a x64 (64 bit) Application

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1]
    "ORA_SDTZ"="America/New_York"
    

    For a x86 (32 bit) Application

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_OraClient11g_home1]
    "ORA_SDTZ"="America/New_York"
    

    Note, ODP.NET Managed Driver does not read any Registry values, so this is more as information for other drivers!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!