StealthBot.net: Resolved: "Overflow" - StealthBot.net

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Resolved: "Overflow"

#1 User is offline   FoXsTeR- Icon

  • Full Member
  • PipPipPip
  • Group: Banned
  • Posts: 521
  • Joined: October-08 09

Posted September 18, 2010 - 11:50 PM

Quote

[01:44:57 AM] Scripting runtime error '6' in DotA League Script: (line 2898; column 0)
[01:44:57 AM] Overflow


Conn.Execute("UPDATE `Users` SET `Games_played` = '" & Games_played + 1 & "', `Wins` = '" & Wins + 1 & "', `Points` = '" & Points + (ScourgePoints/SentPoints*15)+(Streak*2.5) & "', `Current_game` = 'N/A', `Last_game` = '" & ListedGame & "', `Current_streak` = '1', `Last_gain` = '+" & (ScourgePoints/SentPoints*15)+(Streak*2.5) & "' WHERE `Name` = '" & ScourgePlayers(I) & "'")



With Conn.Execute("SELECT * FROM `Users` WHERE `Name` = '" & ScourgePlayers(I) & "'")
               Games_played = .Fields(6)
               Wins = .Fields(4)
               Losses = .Fields(5)
               Points = .Fields(3)
               Streak = .Fields(13)
               BestStreak = .Fields(14)
               If Streak >= BestStreak Then
                    Conn.Execute("UPDATE `Users` SET `Games_played` = '" & Games_played + 1 & "', `Wins` = '" & Wins + 1 & "', `Points` = '" & Points + (ScourgePoints/SentPoints*15)+(Streak*2.5) & "', `Current_game` = 'N/A', `Last_game` = '" & ListedGame & "', `Current_streak` = '" & Streak + 1 & "', `Best_Streak` = '" & Streak + 1 & "', `Last_gain` = '+" & (ScourgePoints/SentPoints*15)+(Streak*2.5) & "' WHERE `Name` = '" & ScourgePlayers(I) & "'")
               ElseIf Streak < BestStreak AND NOT Streak <= 0 Then
                    Conn.Execute("UPDATE `Users` SET `Games_played` = '" & Games_played + 1 & "', `Wins` = '" & Wins + 1 & "', `Points` = '" & Points + (ScourgePoints/SentPoints*15)+(Streak*2.5) & "', `Current_game` = 'N/A', `Last_game` = '" & ListedGame & "', `Current_streak` = '" & Streak + 1 & "', `Last_gain` = '+" & (ScourgePoints/SentPoints*15)+(Streak*2.5) & "' WHERE `Name` = '" & ScourgePlayers(I) & "'")
               ElseIf Streak <= 0 AND Streak < BestStreak Then
                    Conn.Execute("UPDATE `Users` SET `Games_played` = '" & Games_played + 1 & "', `Wins` = '" & Wins + 1 & "', `Points` = '" & Points + (ScourgePoints/SentPoints*15)+(Streak*2.5) & "', `Current_game` = 'N/A', `Last_game` = '" & ListedGame & "', `Current_streak` = '1', `Last_gain` = '+" & (ScourgePoints/SentPoints*15)+(Streak*2.5) & "' WHERE `Name` = '" & ScourgePlayers(I) & "'")
               End If
          End With


Could anyone explain to me why this error is occuring. If you know how to solve it, that'd be even more awesome! ;)

#2 User is offline   Hdx Icon

  • Hdx
  • PipPipPipPipPipPipPip
  • Group: Guests
  • Posts: 1,359
  • Joined: July-31 09

Posted September 18, 2010 - 11:55 PM

Well, you have a shitload of math in there, so I am assuming one, or more of the functions is overflowing there data type.
You should clean up that code, and isolate all the math.
Also, I may be wrong (its been years) but i think you can do something like:
`wins` = `wins` + 1
Erin Go Bragh!
Posted Image

#3 User is offline   FiftyToo Icon

  • StealthBot Developer
  • PipPipPip
  • Group: Guests
  • Posts: 276
  • Joined: July-31 09

Posted September 19, 2010 - 05:32 AM

Also, whenever you are posting a problem with a query, it helps if you post the database schema as well (CREATE TABLE blah blah) so people that help you can recreate your exact tables and types.

With you example, you can probably combine those 3 queries into 1 using IIF inside the actual query, like so...

UPDATE Users SET
    Game_Played = Game_Played + 1,
    Wins = Wins + 1,
    Points = Points + 20,
    Current_Game = 'N/A',
    Last_Game = 'No Idea',
    Current_Streak = Current_Streak + 1,
    Best_Streak =IIF(Current_Streak + 1 > BestStreak, Current_Streak, Best_Streak)
WHERE ID = 2



Doing it like this will prevent the need to select the data before performing the update. Obviously you would need to substitute in the actual values rather than my hard coded values. A query this complex can really take advantage of parameterized queries. Basically, the idea is that your REAL query uses variables (like UPDATE Users SET Wins = @Wins WHERE Name = @Name), and then you add the parameters to your command object, setting the data type and actual values of those parameters. There are MANY benefits of doing it like this, but in your case it will help separate your business logic (ie all the math) with your data logic (ie the query). Its a little more code, but the maintenance will no longer be a nightmare and your code will become nice and tidy, making it easy to discover syntax problems.

52

#4 User is offline   FoXsTeR- Icon

  • Full Member
  • PipPipPip
  • Group: Banned
  • Posts: 521
  • Joined: October-08 09

Posted September 19, 2010 - 10:28 AM

Actually the problem fixed itself somehow... It doesn't error anymore even though I didn't do anything to the code :)

This topic can be resolved if you wish. Thanks for the replies anyways!

#5 User is offline   AwaKening Icon

  • how do ya like me now
  • PipPipPipPipPip
  • Group: Members
  • Posts: 977
  • Joined: August-20 09

Posted September 19, 2010 - 03:17 PM

I have marked this topic as resolved. If you did not receive a satisfactory response please reply and provide as much relevant information as possible.

#6 User is offline   Hdx Icon

  • Hdx
  • PipPipPipPipPipPipPip
  • Group: Guests
  • Posts: 1,359
  • Joined: July-31 09

Posted September 19, 2010 - 05:04 PM

*head desk*
This is why I don't like scripters u.u
Erin Go Bragh!
Posted Image

#7 User is offline   FiftyToo Icon

  • StealthBot Developer
  • PipPipPip
  • Group: Guests
  • Posts: 276
  • Joined: July-31 09

Posted September 20, 2010 - 05:24 AM

There was probably something wrong with the data.

52

#8 User is offline   Hdx Icon

  • Hdx
  • PipPipPipPipPipPipPip
  • Group: Guests
  • Posts: 1,359
  • Joined: July-31 09

Posted September 20, 2010 - 04:22 PM

Ya, but its still a pain when they accept 'the error went away' as a valid fix.
Erin Go Bragh!
Posted Image

#9 User is offline   FoXsTeR- Icon

  • Full Member
  • PipPipPip
  • Group: Banned
  • Posts: 521
  • Joined: October-08 09

Posted September 20, 2010 - 04:35 PM

Yeah I know. I didn't do anything to fix it though, so I don't really know how I "fixed it"

#10 User is offline   FiftyToo Icon

  • StealthBot Developer
  • PipPipPip
  • Group: Guests
  • Posts: 276
  • Joined: July-31 09

Posted September 22, 2010 - 10:07 PM

View PostFoXsTeR-, on 20 September 2010 - 12:35 PM, said:

Yeah I know. I didn't do anything to fix it though, so I don't really know how I "fixed it"


If you can reproduce the problem, then you will be able to find the error much easier than sifting through the entire code.

In your case, the problem went away without changing any code. That could mean a couple of things:

1. You are wrong about not changing code. Either you forgot, dismissing it, or flat out lying.
2. Something your code depends on has been corrected (maybe you were disconnected, couldnt connect to database, file not found, data in the database is different, whatever....)

In your case, I would bet it's related to the data contained in your database. Were some values NULL before and have values now? Did the data types of your columns change? Did the order of your columns change in your select query? These are the types of questions you need to ask yourself when you are trying to reproduce a problem. Play around with the data, changing values to NULL or setting them to values that can cause your code to overflow them. Try deleting your database (back it up first) and starting from scratch.

If you accept the solution of looking the other way, you will have tons of bugs in your code. Its true.

52

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users