HighTechTalks DotNet Forums  

Unable to retrieve schema - Divide by zero error encountered

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Unable to retrieve schema - Divide by zero error encountered in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Stephan Steiner
 
Posts: n/a

Default Unable to retrieve schema - Divide by zero error encountered - 09-17-2007 , 08:14 AM






Hi

Has anybody ever come across this error when working with a DataView on
ASP.NET 2.0?

Here's the funny thing - the grid works fine. However, if I try to edit
columns, I don't have the list of all the available columns in the data
source. If I try to refresh the schema, either in the edit columns mode or
via that sqldatasource directly, I get the abovementioned error - the full
text is

Unable to retrieve schema. Ensure that the ConnectionString and
SelectCommand properties are valid.

Divide by zero error encountered.

However, if I configure the datasource, and go through the usual steps, when
I get to the point where I can test the data source, I do get the expected
results back - thus further underlining that there's nothing wrong with the
underlying connection or select command.

I even set a breakpoint in the selecting event of the sqldatasource to
ensure that the parameters sent to my stored procedure (the data source
calls a stored procedure with two arguments) are correct.

While there's a numeric division in the stored procedure, there are
precautions in the code preventing any possible division by zero, and sine
even Visual Studio manages to get the data in the data source configuration
mode, there's nothing wrong with the data that is being returned, leaving me
with the question what the heck is going on here.

Any insight you might have would be greatly appreciated. In the meantime
I've gone over to configuring the grid manually which seems to work just
fine (I have yet to see any data in the running app though.. )

Regards
Stephan



Reply With Quote
  #2  
Old   
PJ
 
Posts: n/a

Default Re: Unable to retrieve schema - Divide by zero error encountered - 09-24-2007 , 09:55 AM






I had this problem with one of my stored procedures. Solution for me was
to go through it and wherever a divide by 0 could be generated, use
'nullif' to change a 0 value to a null value.

eg
Select @new = @100 / @zero

becomes

Select @new = @100 / nullif(@zero,0)

My stored procedure trapped divide by 0 via logic so it will never be
execute in a live situation and why it was generated in VS2005 is still
a mystery but this change was enough to allow vs2005 to retrieve the
schema info and populate the grid fields etc.


*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.