0
votes

I have read many questions on here that dont quite give the solution and I have tried many variations of using the sqlite datetime(...) or strftime() (though not sure if the latter is recognized in c#), to try an extract a set of column values from a single row but the date fields are returning nothing string and numerics columns are fine. As evidenced by inspecting a watch dt.Rows[0]["ResponseDateTime"] Can anyone point out where I have gone wrong? have tried: (amongst others)

Select field1, strftimetime('%d/%m/%Y %H:%M',resDateTime) as ResponseDateTime, field2 from table

Select field1, datetime(resDateTime), field2 from table

etc

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;
    }
1
Nobody got any ideas on this guys? - Andrew Seabrook

1 Answers

0
votes

Aha got it issue related sqlite fetching dates between dates from database IOS answers this in fact after making the changes everything hunky dory!