Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WHY is - 'GENERATE INSERT UPDATE AND SELECT STATEMENT' greyed out?

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?

like image 678
CGF Avatar asked Dec 22 '22 12:12

CGF


2 Answers

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.

like image 187
tvanfosson Avatar answered Feb 24 '23 12:02

tvanfosson


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 ;-)

like image 30
Steven A. Lowe Avatar answered Feb 24 '23 14:02

Steven A. Lowe