Ambitiousmilky Ambitiousmilky - 18 days ago 6
SQL Question

How to Manually increment SQL column when inserting data depending on a factor C#

Hi There i'm currently building a tracker for myself to keep track of my performance in competitive overwatch, what im currently stuck with is how to keep a track of wins and losses - the way i wish to do this is a combobox in which when the submit button is clicked it checks the text of the comboBox and if the text is win it will increment my win column (at the same time it will insert the rest of the details about the game (Character Played, Game outcome (text), Current SR, and the date the game was played (There are also Losses and Draws columns)))) The reason i cant use auto increment is that it wont always be a win my current database looks like this : CURRENT DATABASE LAYOUT

I have the rest of the information updating fine ( Here is the SQL statement i am using ) I was wondering if there was a way i could add this functionality into the statement?

https://gyazo.com/4367a2510de51a426de589d453ff991d


(Wont let me add a second picture for some reason??)

Thankyou in advance and if any more information is required i will try to provide as best as i can.

Answer

Your database design is bad. You should do the following:

Table Matches. Columns: nvarchar Character, datetime MatchDate, bit IsWin, bit IsLoss, bit IsDraw, int SkillRatingAtTime (add something per-match if I am missing it).

Then you insert a new row for each match played. You can get the number of losses, wins, draws and total games by simply taking the COUNT and adding a WHERE statement.

You don't have to increment anything.

Also, you should look into EntityFramework, makes everything database-related easier ;)