Everything works fine, except one thing. When i try to pull the username of the one with the highest score, the program fails.
The result that i get is 0 instead of le_user
This is the part of code that act's weird:
string query = "SELECT * FROM \"Highscore_List\" ORDER BY Highscore_List.score DESC LIMIT 1";
DataTable recipe = db.GetDataTable(query);
foreach (DataRow r in recipe.Rows)
{
string old_user = r["user_name"].ToString();
int oude_topscore = Convert.ToInt32(r["score"]);
}
And the score is right, just the user name not. And when i leave this part of the query
ORDER BY Highscore_List.score DESC LIMIT 1
The result is still the same. So that isn't the problem.
So what am I doing wrong?
EDIT:
Here is an SQL dump of it:
-- ----------------------------
-- Table structure for "main"."Highscore_List"
-- ----------------------------
DROP TABLE "main"."Highscore_List";
CREATE TABLE "Highscore_List" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"score" INTEGER NOT NULL,
"user_name" INTEGER NOT NULL
);
-- ----------------------------
-- Records of Highscore_List
-- ----------------------------
INSERT INTO "main"."Highscore_List" VALUES (1, 1, 'hui');
INSERT INTO "main"."Highscore_List" VALUES (2, 2, 'Onbekend');
INSERT INTO "main"."Highscore_List" VALUES (3, 3, 'onbekend_tt');
INSERT INTO "main"."Highscore_List" VALUES (4, 2, 'onbekenddd');
INSERT INTO "main"."Highscore_List" VALUES (5, 6, 'le_user');
INSERT INTO "main"."Highscore_List" VALUES (6, 0, 'Onbekend');