Apache OpenOffice (AOO) Bugzilla – Issue 5450
ADO/ Access Autoincrement fails
Last modified: 2006-05-31 14:29:06 UTC
I have created a form that uses a table from an Access database. The primary key is based on an autoincrementing integer. The connection is through ADO 2.6 and later and JET 4. When a new record is created, the record cannot be saved because the autoincrementing value is not generated but remains null.
The value is to be generated by the database backend, not by the frontend (means not by OOo). I darkly remember that we had a bug that we wrote NULL into the autoinc field before saving, instead of leacing it intouched (which would be the correct way). Pierre, What exactly means "cannot be saved"? How does this manifest? I _suppose_ you get an error message, do you? What is the text of this error message?
FS wrote "Pierre, What exactly means "cannot be saved"? How does this manifest? I _suppose_ you get an error message, do you? What is the text of this error message?" FIrst off, sorry about my poor choice of phrase. I work extensively with Delphi and ADO so appreciate that the database backend generates the autoinc. I also believe that (in Access at least) the number is generated when the new record is saved, ie the value is NOT available when the new record is created. This, I suspect, my be the problem especially if the OOo form expects the value on the New record event. Specifically in respect of the error OOo gives, it is "ERROR WRITING DATABASE - Required input field <fieldname> requires value. Please enter value" <fieldname> is, of course, the autoincrementing field. Entering a valid value will save the record but that isn't practical in a larger and busy database.
Hi Frank, please follow up on this issue, Dirk
Marc, can you reproduce this?
Hi, in addition to the problems already reported, I'd like to add the following scenario (Access database through ODBC): Create a table with an auto-increment key field and a text field. Create a OOo form linked to this table with only the text field on the form. The behaviour I would expect would be that when entering a new record in the text field, the autoincremental key field would automatically be taken care of by Access. Instead I get an error "Error inserting the new record " with "[Microsoft][ODBC Microsoft Access Driver]Invalid character value for cast specification (null)". The only way to get out of the field is to undo the data entry, but then OOo crashes.
reassign to clu@openoffice.org
clu->oj: can repro it on 644o 1. create an Access ADO source with url: PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=T:\Teams\QA\DatabaseAccess\Testplan_Requirements\db- types\access\testdb.mdb 2. open table in beamer: Bug-Isz-5450 and insert anything in field: text and leave the row -> Info: Error inserting the new record The field 'autoinc' cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field.
I fixed our ADO implementation. Best regards, Ocke
I note this problem persists in OOo v1.03 and 1.1 beta, also the implication of the previous comment is that the matter is supposed to be fixed. Is this matter still getting attention? BTW, same problem with mySQL databases :(
Hello Pierre, I could not reproduce the bug in a new version. May be this depends on the version of MDAC you use. Could you please try the same with the MDAC version 2.7? And if you still could reproduce it, please attach a simple form and a sample mdb file with just this table. Best regards, Ocke
Hello Mark, the problem with Access and ODBC is that you could create tables which contain auto increment fields, but the driver never tell you again that this column was an auto increment one. So auto increment columns, Access and ODBC do not work well with each other :-( Best regards, Ocke
Created attachment 5948 [details] bug doc
Created attachment 5950 [details] Small form demo of problem, as requested
(for the records: related issue 13926 submitted during investigating this)
Set target
change subcomponent to 'none'
Marc, could you please verify that the bug doesn't occur anymore with a new ver of the MDAC. Tanks, Ocke
rather my turn
tried autoincrement with Acess data source over ADO with mdac 2.7 on an 1.1 oo and it works fine -> means: this bug is fixed - each other problem, if still exist, should have place in an other task
close