P
Paul Delcogliano
Hi all,
I am having a strange problem with the Fill method. Under certain
circumstances, the Fill method is adding an incomplete datarow to my
dataset. This new incomplete row is causing all sorts of errors (as you can
probably imagine). I have to admit that I don't fully understand all of the
circumstances that are causing this problem, but I will attempt to give you
as much information as possible.
Here's the basics. We are using a strongly typed dataset which contains 3
datatables. The datatables are related to each other via data relation
objects. The datatable hierarchy is parent - child - grandchild. The dataset
is databound at runtime to a user control on a windows form. When the form
is first opened, the fill method is called which populates the dataset just
fine.
We start to see problems after updating or inserting new rows in the 2nd
datatable (mentioned as "child" above) via the controls on the user control
bound to the dataset. After successfully saving the changes to the database
via the data adapter's update method, we are clearing the dataset by calling
the dataset's clear method, and repopulating it by calling the fill method
once again. This time, the fill method is returning all of the correct rows
for the child datatable, but is adding a new row to the datatable. This new
row only has the first two columns in it (as opposed to the 20 or so that a
correct row would have). In addition, the new row's rowstate is set to
"Added" and the value for one of the columns (which has it's Autoincrement
property set to true) is -1 (we are seeding with -1 and incrementing -1).
Here's where things start to get really weird. In some cases, if we remove
the data relation from between the child and grandchild datatables, we don't
get this "phantom" row. If we recreate the data relation between the child
and grandchild datatables, the phantom row returns. In other cases, if we
don't bind one control on the user control at runtime, and the data relation
exists between the child and grandchild tables, we get the phantom row.
There are other scenarios where removing the binding in combination with
removing or adding the data relation but nothing seems consistent.
We believe that the problem lies somewhere in the child datatable since this
is the one common element to all of the various scenarios that cause the
phantom row to appear.
I know that there isn't much to go on here, but I'm hoping that someone has
run into a similar situation where calling the fill method mysteriously adds
a row to a datatable. I should mention that we are populating the dataset
from data stored in SQL Server 2000 and are using VS.Net 2003. The
application we are debugging is a WinForms app written in VB.Net. We are
using the .Net Provider for SQL Server to communicate with the db.
Any help would be greatly appreciated.
Paul
I am having a strange problem with the Fill method. Under certain
circumstances, the Fill method is adding an incomplete datarow to my
dataset. This new incomplete row is causing all sorts of errors (as you can
probably imagine). I have to admit that I don't fully understand all of the
circumstances that are causing this problem, but I will attempt to give you
as much information as possible.
Here's the basics. We are using a strongly typed dataset which contains 3
datatables. The datatables are related to each other via data relation
objects. The datatable hierarchy is parent - child - grandchild. The dataset
is databound at runtime to a user control on a windows form. When the form
is first opened, the fill method is called which populates the dataset just
fine.
We start to see problems after updating or inserting new rows in the 2nd
datatable (mentioned as "child" above) via the controls on the user control
bound to the dataset. After successfully saving the changes to the database
via the data adapter's update method, we are clearing the dataset by calling
the dataset's clear method, and repopulating it by calling the fill method
once again. This time, the fill method is returning all of the correct rows
for the child datatable, but is adding a new row to the datatable. This new
row only has the first two columns in it (as opposed to the 20 or so that a
correct row would have). In addition, the new row's rowstate is set to
"Added" and the value for one of the columns (which has it's Autoincrement
property set to true) is -1 (we are seeding with -1 and incrementing -1).
Here's where things start to get really weird. In some cases, if we remove
the data relation from between the child and grandchild datatables, we don't
get this "phantom" row. If we recreate the data relation between the child
and grandchild datatables, the phantom row returns. In other cases, if we
don't bind one control on the user control at runtime, and the data relation
exists between the child and grandchild tables, we get the phantom row.
There are other scenarios where removing the binding in combination with
removing or adding the data relation but nothing seems consistent.
We believe that the problem lies somewhere in the child datatable since this
is the one common element to all of the various scenarios that cause the
phantom row to appear.
I know that there isn't much to go on here, but I'm hoping that someone has
run into a similar situation where calling the fill method mysteriously adds
a row to a datatable. I should mention that we are populating the dataset
from data stored in SQL Server 2000 and are using VS.Net 2003. The
application we are debugging is a WinForms app written in VB.Net. We are
using the .Net Provider for SQL Server to communicate with the db.
Any help would be greatly appreciated.
Paul