Divide by Zero Error [this.Adapter.Fill(dataTable);]  
Author Message
miamikk





PostPosted: .NET Framework Data Access and Storage, Divide by Zero Error [this.Adapter.Fill(dataTable);] Top

I am getting a "Divide by Zero Error Encountered" when I run my ASP.NET application. The error looks like is encountered when filling DataSet.
I have a GridView on frontpage that is configured to get data from a Dataset which uses Stored Procedure to get data. The SP runs perfectly when I run in SQL Server but I don't know why is it throwing an error when I run from ASP.NET.

Any help is really appreciated.

I am attaching some images below to give more information:

Image of Default.aspx page and DataSet

Image of Error

Image of Stored Procedure Code

Image of Output when Stored Procedure is executed in SQL Server




.NET Development16  
 
 
MihaiBejenariu





PostPosted: .NET Framework Data Access and Storage, Divide by Zero Error [this.Adapter.Fill(dataTable);] Top

The error appears due to division operations you are performed in stored procedure.

Try to replace sum (x) / sum (y) with IIF (sum(y) = 0, valueInCaseOfSumIsZero, sum(x)/sum(y)).