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


  • 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

    (I have noticed that when stored procedure is executed in SQL server, it returns a Value '0' in a second table. I am don't know why is "DECLARE @return_value int" and "SELECT 'Return Value' = @return_value" are created in the Stored Procedure when I created SP.



    Monday, October 30, 2006 8:15 PM

All replies

  • 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)).


    Wednesday, November 01, 2006 11:39 PM