Re: Problem with primary keys.
- From: "Mark Ashton" <markash@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 10 Oct 2005 11:00:50 -0700
The conflict between User A & B is likely, it sounds like a classic data
concurrency issue.
You can go read about them in MDSN Technical Articles.
MSDN Home > MSDN Library > .NET Development > ADO.NET > Technical
Articles
--
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
"david.alger@xxxxxxxxxxxxxx" <david.alger@xxxxxxxxx> wrote in message
news:1128933449.754378.65100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi.
>
> Yes, it's the dangers of using an application while it's being
> developed, but I've hit a snag with the system I'm developing and I'd
> appreciate any help.
>
> Users are working with a data-entry program written in C# using ADO.NET
> to enter data into a SQL Server (2000) database.
>
> The system works as follows:
> 1) Open a connection the the DB (sqlconnection)
> 2) Create a sqldataadapter with missingschemaaction= .addkey
> 3) Fill a dataset with a simple query (fetch all records in the current
> task entered by the user).
> 4) The connection is closed.
> 5) A dataview is created for the dataset and a form has controls bound
> to this dataview.
> 6) The user can edit previously created records or add new records.
> 7) Rows are added through DataView.Addnew()
> 8) At regular intervals a connection is re-established with the
> database
> 9) A dataadapter with missingschemaaction=.addkey is created using a
> simple 'SELECT * FROM...' query
> 10) A Sqlcommandbuilder is created
> 11) dataadapter.update(dataset, tablename) is executed.
> 12) connection is closed.
>
> The system seems to work fine for the most part. The problem is rows
> are "disappearing". I.e. I can see them in the dataset on the user's
> machine but not in the database.
>
> The table has a key:
> [ID] [int] IDENTITY (1, 1) NOT NULL ,
> CONSTRAINT [PK_tbl_1] PRIMARY KEY CLUSTERED
> ( [ID] ) WITH FILLFACTOR = 90 ON [PRIMARY]
>
> My guess is that User A is creating a record and the dataset is
> assigning ID x+1. Meanwhile User B is creating a record and also
> getting an ID of x+1.
> When they run the update the user who writes last will "get" the ID and
> for all intents and purposes the other user will lose their data.
>
> Is this likely the problem? How ought one to solve it? I'm currently
> using a simply INT as the ID, I'd hate to have to switch to the larger
> GUID. How can I make sure that the ID is assigned only when the table
> updates, as opposed to the moment dataview.addnew() is executed?
>
> Hope that's reasonably clear and thanks in advance for any help!
>
> regards,
> Dave
>
.
- References:
- Problem with primary keys.
- From: david.alger@xxxxxxxxxxxxxx
- Problem with primary keys.
- Prev by Date: Re: Creating your own provider / database driver
- Next by Date: Re: ado.net - filling new msaccess table with data in a dataset
- Previous by thread: Problem with primary keys.
- Next by thread: Re: Creating your own provider / database driver
- Index(es):
Relevant Pages
|
|