当前位置: 代码迷 >> ASP.NET >> 转换到 datetime 时,转换失败 .以下为代码.请问错误点.Tks
  详细解决方案

转换到 datetime 时,转换失败 .以下为代码.请问错误点.Tks

热度:3116   发布时间:2013-02-25 00:00:00.0
转换到 datetime 时,转换失败 .以下为代码.请教错误点.Tks!
SqlCommand   cmd=new   SqlCommand( "select   TB_Destination_detail   as   地點詳述,DL_Destination   as   地點,ReturnTime   as   預計出發時間,Departure_Time   as   返回時間,Vehicle_plate   as   車牌   from   View_1   where   Departure_Time> = ' "+DateTime.Now+ " ' ",con);


错误提示:

从字元字串转换到   datetime   时,转换失败。

------解决方案--------------------------------------------------------
try:

SqlCommand cmd=new SqlCommand( "select TB_Destination_detail as 地點詳述,DL_Destination as 地點,ReturnTime as 預計出發時間,Departure_Time as 返回時間,Vehicle_plate as 車牌 from View_1 where Departure_Time> = ' "+DateTime.Now.ToString( "yyyy-MM-dd HH:mm ")+ " ' ",con);

------解决方案--------------------------------------------------------
同意ls
------解决方案--------------------------------------------------------
DateTime.Now.ToString( "yyyy-MM-dd HH:mm ")
  相关解决方案