当前位置: 代码迷 >> Oracle开发 >> 大神求教 关于to_date有关问题
  详细解决方案

大神求教 关于to_date有关问题

热度:163   发布时间:2016-04-24 06:26:39.0
大神求教 关于to_date问题
private update(string car,string  intime)
{
...
com.CommandText = "update system set  TKCO='car',INPUTTIME='intime' where TRUCKNO_CN='carnb')";
com.Parameters.AddWithValue("@TKCO", car);
com.Parameters.AddWithValue("@INPUTTIME", intime); 
...
}

报错是intime是时间类型 

在导入的txt中用string类型取到了时间类型 想转换成to_date形式导入数据库  应该怎么改 

我这样改INPUTTIME=to_date(intime,‘yyyy-mm-dd  hh24:mi;ss’)  可是intime还是string类型
------解决思路----------------------
com.CommandText = "update system set  TKCO='car',INPUTTIME='intime' where TRUCKNO_CN='carnb')";
你这不是变量,而是值,语句直接将'intime'字符串更新到inputtime字段
------解决思路----------------------
com.CommandText = "update system set  TKCO='car',INPUTTIME='intime' where TRUCKNO_CN='carnb')";
要改成:
com.CommandText = "update system set  TKCO=@car,INPUTTIME=@intime where TRUCKNO_CN='carnb')";
吧!
变量前面要加@