asp.net report DbSource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm running into a frustrating problem.

ASP.NET 2.0 web application, against SQL'05, I'm trying to run a report
against a 'table provider' (query) that excutes well within SQL MGT studio,
and within the data environment.

However, when the report is executed in a web report viewer, the report
engine comes back with:

An error has occurred during report processing.
Exception has been thrown by the target of an invocation.
Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints.

Ideas?
 
Hi David,

The query is producing data of a format that is inconsistent with the schema
for the DataTable in which it is being stored for the report.

Check that the DataTable schema allows nulls for nullable columns in the
query output and make sure that your query returns enough result sets and
records
to fill all related tables in the DataSet so that foreign key constraints
are not violated, or just set the DataSet.EnforceConstraints property to
false.

- Dave Sexton
 
Hi Dave

The same query performs just fine in any other consumer. I was able to use
the exact same query with SQL'05 reprting services, and with an asp grid. The
only one breaking is the report viewer.

Also, I was unable to find the location where I can apply the
DataSet.EnforceConstraints in code, can you give me a pointer?

Thanks
 
Hi David,

Since you can't find the DataSet I must assume that you have configured a
strong-Typed DataSet and associated its TableAdapter with an
ObjectDataSource for your report, correct?

Unfortunately you don't have access to the underlying DataSet until after it
has been created and filled. Your best bet is to try to narrow down which
DataColumn is causing the trouble and fix the schema.

Another option is to bind the ObjectDataSource to a DataSet and fill the
DataSet in your code-beside file. This way, you can set EnforceConstraints
to true, although I really do think you should just fix the schema instead.

- Dave Sexton
 
Hi Dave

It's still odd to me that the table adapter fills a grid without a murmur
and failes on the report. And, the base query is used by SQL'05 reporting
services as is without any issues. I believe that there is a bug in the
reporting engine, I wish MS will step in here.

See below

Dave Sexton said:
Hi David,

Since you can't find the DataSet I must assume that you have configured a
strong-Typed DataSet and associated its TableAdapter with an
ObjectDataSource for your report, correct?
yes

Unfortunately you don't have access to the underlying DataSet until after it
has been created and filled. Your best bet is to try to narrow down which
DataColumn is causing the trouble and fix the schema.

that's the part that stumps me, I looked at the data, there is no issue of
null values, even though, the query does create duplicates of a primary key
from a master list.
Another option is to bind the ObjectDataSource to a DataSet and fill the
DataSet in your code-beside file. This way, you can set EnforceConstraints
to true, although I really do think you should just fix the schema instead.

Thanks, I'll keep this in mind.
 
Hi David,
that's the part that stumps me, I looked at the data, there is no issue of
null values, even though, the query does create duplicates of a primary
key
from a master list.

Well the error is definitely being thrown by the DataSet although it might
not be specific to null values. Is there more than one DataTable in your
DataSet with DataRelations that provide foreign-key constraints? As a
simple test try removing those DataTables from the DataSet that are not
being used in the report.

Duplicate primary keys could very well be the issue here as well if you have
defined a unique constraint on your key column by setting Unique to true in
the .xsd designer or setting the key column as the primary key. Removing
those constraints, if they exist, might solve your problem although you
should probably make a new schema for your report data void of any
constraints that might be causing the error, not only as a test but for
runtime as well.

- Dave Sexton
 
Back
Top