System.Data.SqlClient.SqlException: Divide by zero error encountered. (partial fix included)

Topics: Developer Discussion
Nov 8, 2007 at 1:03 AM

I found an issue with the 6490 change set on October 17th. I'm going to download and merge my code base with the Oct 31 version soon, but here's the issue in case it hasn't been found and repaired yet.

When viewing a forum thread /forum/Thread.aspx?th=nnn I was getting an SQL exception: Divide by zero error encountered.

After about two hours of debugging, I traced it down to the GetThreadPage stored procedure. I couldn't figure out why, but for some reason it was being passed zero for the PageSize parameter. I'm assuming the user changed something, but I couldn't see where it was.

In any event, I added this code to the beginning of the stored procedure so that it won't crash and will display a reasonable result in the event of a bad page size parameter.

IF @PageSize < 1
BEGIN
Set @PageSize = 10
END


I still have an open request:

How did they set the value to zero in the first place? That seems like a bug.



(Thanks for all the work and the great tool!)
Coordinator
Nov 8, 2007 at 3:08 AM
That might be related to a WebSettings bug. I will check that out. Maybe we just need to pull the setting from the WebSettings table to take out an extra parameter.