0
我插入到一个Oracle数据库表使用下列插入字符串(约 - 有140列,所以我不会显示所有):甲骨文将ISO日期到计算机的语言环境日期/时间
“INSERT INTO AMS_ASSET_CS_IFACEOUT VALUES('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”。
我不完全确定为什么......我有什么选择?我需要只是代码格式的转换,我正在给回ISO
问候,
肖恩·安德森
只是为了确认,这是解决这个问题的可接受的方法吗? [IgnoreFirst] [DelimitedRecord( “”)] [序列化] 公共类AmsAsset { 公共字符串assetnum {得到;组; } public string changeby {get;组; } public string changedate { get { return String.Format(“{0:YYYY-MM-DD}”,changedate);} } 设置 {} } .... 编辑:EHH,格式化变成了可怕的。我会修复它。谢谢! – 2010-12-11 01:33:15