public Task(int id) { DataBase db = new DataBase(); DataTable queryResult = db.GetQuery(string.Format("select * from tasklist where id = '{0}'", id+1)); if (queryResult.Rows.Count != 0) { _id = (int)queryResult.Rows[0]["id"]; _name = (string)queryResult.Rows[0]["task_name"]; _answer = (int)queryResult.Rows[0]["task_answer"]; _methodName = _name; } else throw new System.Exception("Can't find task"); }