mardi 11 août 2015

Count SQL Query not returning expected value

I'm trying to have a method return a count statement.

    public int getSettingsCount(string UserId, string Setting)
    {
        int LastSetting;
        //var user = new SqlDataLayer();
        using (var db = new SQLite.SQLiteConnection(this.DBPath))
        {
            {
                List<int> _setting = db.Query<int>("SELECT COUNT(*) FROM QTabSettings WHERE UserId = 1058 AND Setting = 'ServerDropdown' ORDER BY TimeStamp DESC LIMIT 1;");
                LastSetting = Convert.ToInt32(_setting.SingleOrDefault());
            }
            return LastSetting;
        }
    }

When I execute the query it returns the correct value (6). However I am getting the value (0) from my above query.

How can I get the method to return the count as an int?

Aucun commentaire:

Enregistrer un commentaire