Dataset not populating

  • Thread starter Sergey Poberezovskiy
  • Start date
S

Sergey Poberezovskiy

Hi,

I created a dataset by dragging a (SQL Server) stored
procedure from the Servers pane. The dataset consists of
three tables that are not linked (at least I do not
enforce contraints).

But when I try to populate the dataset by

SqlClient.SqlDataAdapter.Fill(ds, tableName)

I receive the following error:
"Failed to enable constraints. One or more rows contain
values violating non-null, unique, or foreign-key
constraints."

Please note that the same code works fine for a different
dataset, so there are no syntax errors.
I have checked that all the fields that are not marked as
minOccurs="0" return not Null values; I even tried to set
minOccurs="0" for all fields in the dataset - same result.

Please help....
 
S

Sahil Malik

Simple .. the data you are filling into your dataset contains some data that
does not satisfy the constraints set on your dataset.

What constraint? That depends, but you can atleast view the data by setting
EnforceConstraints = false and then looking through the data to find out
which constraint is not being satisfied.

- Sahil Malik
You can reach me thru my blog -
http://www.dotnetjunkies.com/weblog/sahilmalik
 
S

Sergey Poberezovskiy

Sahil,

My problem was that the dataset variable I was trying to
fill was initialized to a different dataset (I just copied
the code and forgot to change it). But using Enforce
Contraints = False I was able to look at the data.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top