I am currently working on WP8 SQlite database and my requirement to get the total count of records whose name=something.
I have tried below function but it doesn't work in sqlite in WP8 but works fine in SQLite Add-On in Mozilla FireFox Browser and other tool such as SQLite Browser.
public int getTotalCatgeorieswithSameName(string category_name) {
SQLiteConnection connection = null;
try
{
connection = getSQLiteConnection();
string query = string.Format("select count(name) from TABLE_NAME where name ='{0}'", name);
var count = connection.Query<T>(query);
return count.Count;
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString() + ex.Message);
return 0;
}
finally
{
if (connection != null)
connection.Close();
}
}
But it gives wrong data. Please someone suggest what I am doing wrong ?
Aucun commentaire:
Enregistrer un commentaire