Unable to add to table with Autonumber column with RODBC

I am trying to insert a new row into a table in a Microsoft Access database using RODBC. The problem is that the primary key column is autonomous, and it does not seem to allow me to skip this column. I am using the sqlSave function with append = TRUE and a single row data frame. I tried the following:

1: completely leave the columns from the data block. This results in an error:

Error in odbcUpdate(channel, query, mydata, coldata[m, ], test = test,  : 
   missing columns in 'data'

2: Setting the primary key column value to an integer NA. This gives me:

Error in sqlSave(conn, exptrow, table = "archiverapp_experiments", append = TRUE,  : 
  unable to append to table ‘archiverapp_experiments’

And the diver error with verbose = TRUE:

23000 -1504 [Microsoft][ODBC Microsoft Access Driver] You tried to assign the Null value to a variable that is not a Variant data type.

3: Setting the PK value to zero, as I saw in the answer in another StackOverflow entry. This worked for the first time, but actually sets PK to zero, so it doesn't work again.

, , PK, . , , , autonumber. ?

+1

Source: https://habr.com/ru/post/1689225/


All Articles