views:

563

answers:

2

Why in the ADVANCE section when I 'configure data source' is the 'GENERATE INSERT UPDATE AND SELECT STATEMENT' greyed out? On some tables it isn't greyed out and works fine.

I know that a way around this can be achieved by changing the autogenerateeditbutton tag to true in properties and you can edit this way - but when this is done there is no update to the database when you attempt.

It was also mentioned that this could be to do with setting up a primary key when I looked on forums on this matter. I couldn't get a conclusive answer though.

The error in the browser is as follows:

NotSupportedException: Updating is not supported by data source 'AccessDataSource1' unless UpdateCommand is specified.

Any ideas how to update the database with these problematic tables? Why are they problematic?

How is the Primary Key alocated to the table. Should this be done in Access? Can it be done in VS08 and how?

+3  A: 

In order for the insert/select/update statements to be automatically generated, the table has to have a primary key so that code to select the correct row upon insert or to update knows which row to select. If you don't have a column in the table that has unique values it is possible for more than one row to match the one that should be updated. Using a primary key allows designer to generate code that reliably chooses the correct row to update.

tvanfosson
How is the Primary Key alocated to the table. Should this be done in Access? Can it be done in VS08 and how?
CGF
See this article: http://office.microsoft.com/en-us/access/HA100140991033.aspx
tvanfosson
You don't have to have Access to add a primary key to a table in a Jet MDB -- you only need to know the correct DDL and have an ODBC or OLEDB driver.
David-W-Fenton
+1  A: 

see tvanfosson's answer re primary key, that is one possibility. You will also get this behavior if your select statement uses a view instead of a direct table.

you can get around this by generating or hand-coding the xml in the .xsd file, but that is a fairly hardcore solution ;-)

Steven A. Lowe
This one has caught me before, Views that dont exist in the DB but are made in VS instead cannot have raw update routines. You can add whatever queries manually though, and usually you dont want all four native ones anyway.
Karl
"Views?" There's no such thing in a Jet MDB.
David-W-Fenton
@[David W. Fenton]: there was no ms-access tag when i wrote this answer, and no mention of Access.
Steven A. Lowe