2010-12-11 1 views
0

にISO日付を変換する(約 - 私はそれをすべて表示されませんので、140個の列があります):Oracleは、私は次の挿入文字列を使用してOracle DB表に挿入するコンピュータのロケールの日付/時刻

「INSERT INTO AMS_ASSET_CS_IFACEOUTを「012c」、「abcdef」、「abcdef」、to_date(「2010-01-31」、「YYYY-MM-DD」)、...)」

その後、数秒後に次のコードスニペットを実行します:

/// <summary> 
    /// Function: GetRecord 
    /// Description: Creates a new AMS-Asset and populates the 
    /// properties of this asset by evaluating properties provided 
    /// by the OracleDataReader. 
    /// </summary> 
    /// <param name="reader"> One record of information from the open connection.</param> 
    /// <returns> A fully created AMS-Asset record. </returns> 
    private static AmsAsset GetRecord(OracleDataReader reader) 
    { 
     AmsAsset newRecord = new AmsAsset(); 

     for (int propertyIndex = 0; propertyIndex < reader.FieldCount; propertyIndex++) 
     { 
      string propertyName = reader.GetName(propertyIndex).ToLower(); 
      string propertyValue = reader.GetValue(propertyIndex).ToString(); 
      int propertyValueAsInteger = 0; 

      bool isPropertyAnInteger = Int32.TryParse(propertyValue, out propertyValueAsInteger); 

      if (isPropertyAnInteger) 
      { 
       newRecord.GetType().GetProperty(propertyName).SetValue(newRecord, propertyValueAsInteger, null); 
      } 
      else 
      { 
       newRecord.GetType().GetProperty(propertyName).SetValue(newRecord, propertyValue, null); 
      } 
     } 

     return newRecord; 
    } 

私のデータベースに挿入された日付の値は、 "1/31/2010 12:00:00 AM"として返されます。

私は完全にはわかりません...私のオプションは何ですか?私はあなたが明確な「YYYY-MM-DD」を使用してデータベースに挿入されたので、私はISOに戻っ

よろしく、

ショーン・アンダーソン

答えて

1

を与えられてるだけのフォーマットからの変換をコーディングする必要がありますかフォーマット日付、それは正しくデータベースに格納されます。

読んでその日付を表示すると、フォーマットは地域の設定に依存します。

明示的なフォーマット指定子を使用して表示することをお勧めします。

+0

これを確認するだけで、これはこの問題を修正するための受け入れ可能な方法でしょうか? [IgnoreFirst] [DelimitedRecord( "")] [シリアライズ] パブリッククラスAmsAsset {パブリック文字列assetnum {得ます。セット; } パブリック文字列changeby {get;セット; } public string changedate { get { return String.Format( "{0:YYYY-MM-DD}"、changedate); }は{} } .... EDITを設定:EHH、ひどい判明書式。私はそれを修正するでしょう。ありがとう! –

関連する問題