在过去的 5 个小时里,我一直在努力让这个程序正常工作。我已经尝试将它修剪到可以工作并以此为基础的程度,但仍然没有成功。我非常感谢一些帮助,因为我必须在明天早上以工作状态展示这个项目。
我已经修剪了我的代码(因为它很长),但问题仍然很明显。
sqlCon.Connected := true; //TSQLConnection
sqlUsers.Active := true; //TSQLTable
sqlGames.Active := true; //TSQLTable
sqlPredictions.Active := true; //TSQLTable
sqlUsers.First;
//All following variables are integers.
rugbyChampionshipScore := 10;
rugbyChampionshipGamesPredicted:= 10;
rugbyChampionshipGamesCorrect:= 10;
rugbyChampionshipGamesAlmost:= 10;
rugbyChampionshipGamesWrong:= 10;
currieCupScore := 10;
currieCupGamesPredicted := 10;
currieCupGamesCorrect := 10;
currieCupGamesAlmost := 10;
currieCupGamesWrong := 10;
sqlQueryUpdate.Close; //TSQLQuery
sqlQueryUpdate.CommandText := 'UPDATE users SET overallScore=:parScore, overallGamesPredicted=:parGamesPredicted, overallGamesCorrect=:parGamesCorrect, overallGamesAlmost=:parGamesAlmost, overallGamesWrong=:parGamesWrong, overallAccuracy=:parAccuracy WHERE username=:parUsername';
sqlQueryUpdate.Params.Clear;
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parUsername', ptUnknown).AsString := sqlUsers.FieldByName('username').AsString;
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parScore', ptUnknown).AsInteger := Round((rugbyChampionshipScore + currieCupScore) / (rugbyChampionshipGamesPredicted + currieCupGamesPredicted));
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parGamesPredicted', ptUnknown).AsInteger := rugbyChampionshipGamesPredicted + currieCupGamesPredicted;
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parGamesCorrect', ptUnknown).AsInteger := rugbyChampionshipGamesCorrect + currieCupGamesCorrect;
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parGamesAlmost', ptUnknown).AsInteger := rugbyChampionshipGamesAlmost + currieCupGamesAlmost;
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parGamesWrong', ptUnknown).AsInteger := rugbyChampionshipGamesWrong + currieCupGamesWrong;
sqlQueryUpdate.Params.CreateParam(ftUnknown, 'parAccuracy', ptUnknown).AsInteger := Round(100 / (rugbyChampionshipGamesPredicted + currieCupGamesPredicted)*(rugbyChampionshipGamesCorrect + currieCupGamesCorrect) + ((rugbyChampionshipGamesAlmost + currieCupGamesAlmost)/2));
sqlQueryUpdate.ExecSQL();
sqlQueryUpdate.Close;
sqlUsers.Active := false;
sqlGames.Active := false;
sqlPredictions.Active := false;