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
PJ - 24 Sep 2007 14:55 GMT
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.