Concurrency violation

  • Thread starter Thread starter Zhuo Li
  • Start date Start date
Z

Zhuo Li

Hi, I get this error when I try to save a datatime field to the database
using OdbcDataAdapter.Update method.
oAdapter.UpdateCommand.CommandText is like: "update aTable set effetive_from
=? where primarykey=?"

The parameter related to this field is like:

oAdapter.UpdateCommand.Paramteres.Add(new OdbcParameter("effective_from",
Odbctype.datetime, 8, "effective_from");

The database is Sybase ASA 9.0. The column effective_from's type is datatime
in the database.

Any suggestions/ideas?

Thanks, Zhuo
 
Hi, I get this error when I try to save a datatime field to the database
using OdbcDataAdapter.Update method.
oAdapter.UpdateCommand.CommandText is like: "update aTable set
effetive_from =? where primarykey=?"

The parameter related to this field is like:

oAdapter.UpdateCommand.Paramteres.Add(new
OdbcParameter("effective_from", Odbctype.datetime, 8, "effective_from");

The database is Sybase ASA 9.0. The column effective_from's type is
datatime in the database.

Any suggestions/ideas?

Thanks, Zhuo

The simplest way is to disable concurrency checking. In your database
set up click on the table and then check the settings, advanced from
memory and remove it. There are multiple descriptions of how to handle
the problem (generally with autonumber primary keys) but if you are using
a database exclusively it is not worth the effort

Ken
 
Thank you for your reply. I think that it is something to do with the
datetime field and the dataset. When the dataset tries to save a row to the
database, it compares its "Original data"of the row with what is in the
database. This comparison always result in difference in the datetime field.
If there were a simple solution, there would be something in the dataset
configuration to set the rule of comparing two datetime values only upto
second. Any idea?

Thanks,
Zhuo
 
Thank you for your reply. I think that it is something to do with the
datetime field and the dataset. When the dataset tries to save a row to
the database, it compares its "Original data"of the row with what is in
the database. This comparison always result in difference in the
datetime field. If there were a simple solution, there would be
something in the dataset configuration to set the rule of comparing two
datetime values only upto second. Any idea?

I can describe a problem I had and perhaps that will help you.

DateTimePicker associated with field. Field was sometime null in the
database. When you picked a new row if (and only if) the field was null
the control got an is null exception and 'rejected' the change of
position. I worked around this by disconnecting the picker from the
database and manually setting it with an onchange event on the
datasource. Very clunky.

I don't get the second message, the difference between two dates is a
timespan. If they are different and you are changing them the database
does not care. If you want to make them null then the automatic
database build will create a method SetFeildNull() and it can be checked
with IsFieldNull().

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top