2013-07-19 74 views
0

我已经阅读了很多关于这里的问题,并不完全给出解决方案,我尝试了许多使用sqlite datetime(...)或strftime()(尽管不知道是否后者在c#中被识别),尝试从单行中提取一组列值,但日期字段没有返回任何字符串和数字列很好。 通过检查手表dt.Rows [0] [“ResponseDateTime”] 证明任何人都可以指出我哪里出了问题? 曾尝试:(主要)如何从c#中的sqlite行得到DateTime值

选择FIELD1,strftimetime( '%d /%米/%Y%H:%M',resDateTime)作为ResponseDateTime,从表

选择FIELD1 FIELD2,日期时间(resDateTime),从表中字段2

public DataTable GetDataTable(string sql) 
{ 
    DataTable dt = new DataTable(); 
    try 
    { 
    //with the following the date field is not getting any date datat into the field 
    // SQLiteConnection cnn = new SQLiteConnection(dbConnection); 
    // SQLiteCommand command = new SQLiteCommand(sql, cnn); 
    // cnn.Open(); 
    // SQLiteDataAdapter myAdapter = new SQLiteDataAdapter(command); 
    // myAdapter.Fill(dt); 

      SQLiteConnection cnn = new SQLiteConnection(dbConnection); 
      cnn.Open(); 
      SQLiteCommand dbCommand = cnn.CreateCommand(); 
      dbCommand.CommandText = sql; 

      SQLiteDataReader executeReader = dbCommand.ExecuteReader(CommandBehavior.SingleResult); 
      dt.Load(executeReader); // <-- FormatException 

      cnn.Close(); 
     } 
     catch (Exception crap) 
     { 
      OutCrap(crap); 
      //throw new Exception(crap.Message); 

     } 
     return dt; 
    } 
+0

没有人对这个家伙有任何想法? –

回答