AutoIncrementSeed CHANGES after DataSet.Fill

  • Thread starter Thread starter Trygve Lorentzen
  • Start date Start date
T

Trygve Lorentzen

Hi,

this was one of a numerous really annoying issues when moving from .NET 1.1
to .NET 2. After I fill my DataSet with values from the database it sets all
AutoIncrementSeed values automatically to the next number in the sequence. I
want to keep the AutoIncrementSeed at -1 to avoid conflicts with local
in-mem DataSet rows and actual rows in the database.

Is this a "feature" or a bug in ADO.NET2?

<frustration>.NET2 is just so annoying and VS 2005 is probably worse than VS
2003 in terms of speed and stability (I suspect my DevX 3rd party components
are also to blame). Phu, just had to let my frustration out...</frustration>

/Trygve
 
Hi Trygve,

Are you sure?
sampleTableAdapter1.Fill(dataSet11.Sample);
Debug.WriteLine(dataSet11.Sample.IdColumn.AutoIncrementSeed);
Debug.WriteLine(dataSet11.Sample.IdColumn.AutoIncrementStep);
Result is -1, -1.
 
Hi Trygve,

Are you sure?
sampleTableAdapter1.Fill(dataSet11.Sample);
Debug.WriteLine(dataSet11.Sample.IdColumn.AutoIncrementSeed);
Debug.WriteLine(dataSet11.Sample.IdColumn.AutoIncrementStep);
Result is -1, -1.
 
That would make sense because the designer is mimicking the contents of the
actual database tables. Change the dataset seed and increments to -1.
 
Hi Miha,

yes, I'm 100% sure that this happens in my project. But after investigating
more I suspect it is the MySQL Connector from Corelab that is the reason for
this behaviour since I have also changed the version of this component in
the move to .NET 2. I have asked the Corelab developers and await an answer
from them. In the meantime I just have to be careful setting the Seed back
to -1 after filling the DataSet.

Best regards,
Trygve Lorentzen

Miha Markic said:
Hi Trygve,

Are you sure?
sampleTableAdapter1.Fill(dataSet11.Sample);
Debug.WriteLine(dataSet11.Sample.IdColumn.AutoIncrementSeed);
Debug.WriteLine(dataSet11.Sample.IdColumn.AutoIncrementStep);
Result is -1, -1.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Trygve Lorentzen said:
Hi,

this was one of a numerous really annoying issues when moving from .NET
1.1 to .NET 2. After I fill my DataSet with values from the database it
sets all AutoIncrementSeed values automatically to the next number in the
sequence. I want to keep the AutoIncrementSeed at -1 to avoid conflicts
with local in-mem DataSet rows and actual rows in the database.

Is this a "feature" or a bug in ADO.NET2?

<frustration>.NET2 is just so annoying and VS 2005 is probably worse than
VS 2003 in terms of speed and stability (I suspect my DevX 3rd party
components are also to blame). Phu, just had to let my frustration
out...</frustration>

/Trygve
 
I don't think this makes sense since the dataset is just an in-mem
representation of data that are later to be written to the database. The
Autoinc number in the dataset should not at all try to mimic the contents of
the database since it would cause conflicts when writing the data back to
the database. What if other users have inserted new rows and the AutoInc
values are already used in the DB?

Anyway, as long as I'm aware of the issue I can make sure I set the seed
back to -1 after filling the dataset. It was that the behaviour had changed
I didn't like, more than that it is a big problem once I know it happens :)

Best regards,
Trygve Lorentzen
 
Set both the seed and increment to -1. This is done specifically to prevent
the "conflict" you mention.
 
Back
Top