Duplicate new records appear when inserting using a web form

  • Thread starter Thread starter Bob Jones
  • Start date Start date
B

Bob Jones

We have an ASP.net application that targets an Acces2002
database file for records storage.

The app is a nutrition tracking and management database
system; it generally works perfectly.

However, if our hosting server is very busy due to high
work load, and a page response takes a while (say, 2
minutes), then when the updated page arrives, we
sometimes note that the post back has been duplicated.

This only seems to happen when a page request involves a
new record insert action.

After the page displays, we sometimes see that the new
record has been inserted twice. Since ours is a database
system, this is not good!

The page does contain 2 textboxes that have "on change
autopostback" enabled; but no changes in these text boxes
is involved with the record insert actions. See KB
828979.

Can anyone suggest what may be going on. Can we prevent
this so out data is not inaccurate?

Thank you.
 
Can you use the data that is being submitted to generate a primary key from
that, so that if there is an attempt to enter the same data a second time,
it won't happen due to primary key constraints?

This means if you are using autonumbering or GUIDS, you would need to change
your PK scheme.

Another way is to see that the same exact field values are not present in
another row in the table before doing the insert.
 
IMHO, the best way to solve this is through the use of Keys on the table.
If you define them correctly, the DB won't accept dups and you don't have to
worry about client side logic to prevent this. If integrity is critical,
there's only upside by using Keys b/c nothing unforseen like the user
clicking on a button twice or whatever can put duplicate data there.

HTH,

Bill
 
Thank you for the input.

Our Access2002 database record store uses auto number
keys as a primary key; there is a "main" table that holds
a description of a recipe or meal; and a related table
that holds "ingredients".

Our system has been specifically designed to allow the
entry of "duplicate" records (with the exception of the
unique auto number primary key). This is necessary to
support certain required operational functionality.

We would normally use the new record's auto number key to
prevent a dup entry; but that number is not available
until after the new record is created, and a page is
returned from a post back. Hence our dilemma.

Can you tell me why a duplicate insert is possible from a
single post back (request) click?

The problem only shows up when our server is very slow to
respond to a request. The problem has showed up when we
are sure that only one (click) request was made.

Thank you.
 
Back
Top