I connected the App to an SQL server database...

(Mohamed Gaber) #1

I connected the App to an SQL server database but whenever I edit a column and then try to sync, I get this error:

Unable to add/edit/delete row in table ‘dbo.Dataa’. → The _RowNumber column is not a valid key column as it does not exist in the database

I don’t have that _RowNumber column in the table in my database and It can’t be removed as it’s greyed out. How can I fix this problem?

(Tammi Canelli) #2

Did you try making one of the other columns that is in your SQL db the key?

(Mohamed Gaber) #3

None of these columns should be unique, If I make any other column a key, that means that this column shouldn’t have any repetitions which does go with the data I need to collect.

(Dinh Nguyen Nguyen) #4

@Mohamed_Gaber Hi Mohamed, when you edit a row in your app, AppSheet will construct and execute a SQL query to make the corresponding change to the row in your database. The constructed query will have a WHERE clause for identifying the row to edit. This WHERE clause relies on the key column of the table to find the row. However, the current key column of your table is the _RowNumber column, which does not exist in your database. As a result, the query will fail.

As a rule of thumb, you should never use the _RowNumber column as the key column if your table comes from a SQL database. To fix this problem, you must choose a different column that exists in the database as the key column. Ideally, this column should also be the primary key column of your SQL table, although any column that has unique values for each row will also work.