Doing this solves folowing scenario, a very common scenario that is well
known. I have send you a little app that i think was good enough to
demonstrate this secnario. More, Microsoft code works differently as you can
saw.
We have a table and the primary key in that table is generated when we
insert rows in the database. The problem is how to handle new rows primary
keys in the DataSet. The approach is to use fake PK in DataTable:
1. We specify PK in DataTable to be AutoIncremented, with a negative
AutoIncrementStep and AutoIncrementSeed. This solves possible conflicts
with database generated keys.
2. The way to update the real PK values for new rows is by using Merge
method. The Merge method use DataRowVersion.Original to match rows. If
DataRowVersion.Original does not exists Merge use DataRowVersion.Current,
but in this case we will have two rows instead of one. That's why we need
if (statementType == StatementType.Insert)
{
row.AcceptChanges();
}
in DataAdapter Update method
Microsoft does this in DbDataAdapter.Update implementation. SqlProvider does
not override this method and MySQL provider either.
I think this usage scenario and Microsoft implementation is good enough to
do the same in FbProvider if you choose to override Microsoft implementation
of
DbDataAdapter.Update method.
I want to support Firebird database in my application but if FbProvider
behaviour is not the same as Microsoft SqlAdapter what shall I do ? Modify
Fb provider source for every release ?
You can read about this scenario here:
http://msdn.microsoft.com/msdnmag/issues/03/07/DataPoints/
http://www.akadia.com/services/dotnet_autoincrement.html
----- Original Message -----
From: "Carlos Guzmán Álvarez" <[EMAIL PROTECTED]>
To: "For users and developers of the Firebird .NET providers"
<[email protected]>
Sent: Thursday, November 16, 2006 9:09 PM
Subject: Re: [Firebird-net-provider] FbDataAdapter problem
> Hello:
>> if (statementType == StatementType.Insert)
>> {
>> row.AcceptChanges();
>> }
>
> I'm not going to do this unless there are any good argument for doing it
> only for inserts.
>
>
> --
> Carlos Guzmán Álvarez
> Vigo-Spain
>
> http://carlosga.wordpress.com
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Firebird-net-provider mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider