locked
Divide by zero error RRS feed

  • Question

  • User1510859543 posted

    I am getting the following error on one of our asp.net pages and I cannot figure out where the error is occurring.  I am only doing division in one place in code and that is bypassed if the "divide by" value is zero.  Any help is appreciated.

    An unhandled exception occurred:
    Message: Divide by zero error encountered.
    
     Stack Trace:
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
       at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
       at System.Data.SqlClient.SqlDataReader.Read()
       at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
       at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
       at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       at System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
       at System.Web.UI.WebControls.ListView.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
       at System.Web.UI.WebControls.ListView.CreateChildControls()
       at System.Web.UI.Control.EnsureChildControls()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    
    

    Monday, January 13, 2014 11:50 AM

Answers

  • User-760709272 posted

    The error is coming from your SQL rather than your code.  Trace the SQL call that is throwing the error and look at the SQL being executed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 13, 2014 11:58 AM

All replies

  • User-760709272 posted

    The error is coming from your SQL rather than your code.  Trace the SQL call that is throwing the error and look at the SQL being executed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 13, 2014 11:58 AM
  • User753101303 posted

    Hi

    one place in code

    Where ? Currently it happens in a SQL statement. Double check this SQL statement if not already done (or show this statement if you need further help)...

    Monday, January 13, 2014 12:00 PM
  • User1510859543 posted

    There are 3 SQL stored procedures used on this page.  I ran all of them manually and did not get an error.

    I removed the one place in the code-behind page that was doing division and it still fails so I think you are right about it being in SQL.

    Is there any way other than running to sp's manually that I can find the error?

    Monday, January 13, 2014 12:15 PM
  • User-760709272 posted

    If you have SQL Profiler then run that, it will show you all the commands and params going to and coming from your database, it should also show you any exceptions that are happening.

    Monday, January 13, 2014 2:49 PM