WHY - "GENERAL UPDATE INSERT AND SELECTION OF APPLICATION" sat down?

Why in the ADVANCE section when I "configure the data source" displays "GENERATE INSERT UPDATE AND SELECT STATEMENT"? On some tables it is not grayish and works great.

I know that this can be achieved by changing the autogenerateeditbutton tag to true in the properties, and you can edit this path, but when this is done, there will be no database when trying to update.

It was also mentioned that this could be related to setting up the primary key when I look at forums on this subject. However, I could not get a final answer.

The error in the browser is as follows:

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

Any ideas on updating the database using these problem tables? Why are they problematic?

How the primary key is placed in the table. Should this be done in Access? Can this be done in VS08 and how?

+3
source share
3 answers

In order for the insert / select / update statements to be automatically generated, the table must have a primary key, so that the code to select the correct row when inserting or updating knows which row to select. If you do not have a column in the table that has unique values, it is possible that more than one row corresponds to the one that needs to be updated. Using a primary key allows the developer to generate code that reliably selects the correct row for updating.

+7
source

. tvanfosson answer re primary key, . , select .

, xml .xsd, ; -)

+1

Create a data source with this view: The primary key is the primary key. permission to view to insert, update, select, delete for such a user:

"DeleteCommand =" DELETE FROM [VW_Security_UK_UserAccess] WHERE [MainKey] = @MainKey "

                InsertCommand="INSERT INTO [VW_Security_UK_UserAccess] ([UserName], [HasAccess], [ApplicationDefinitionmainkey], [SortOrder]) VALUES (@UserName, @HasAccess, @ApplicationDefinitionmainkey, @SortOrder)" 
                SelectCommand="SELECT [MainKey], [UserName], [HasAccess], [ApplicationDefinitionmainkey], [SortOrder] FROM [VW_Security_UK_UserAccess]" 
                UpdateCommand="UPDATE [VW_Security_UK_UserAccess] SET [UserName] = @UserName, [HasAccess] = @HasAccess, [ApplicationDefinitionmainkey] = @ApplicationDefinitionmainkey, [SortOrder] = @SortOrder WHERE [MainKey] = @MainKey">
                <DeleteParameters>
                    <asp:Parameter Name="MainKey" Type="Int16" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="UserName" Type="String" />
                    <asp:Parameter Name="HasAccess" Type="String" />
                    <asp:Parameter Name="ApplicationDefinitionmainkey" Type="Byte" />
                    <asp:Parameter Name="SortOrder" Type="Int32" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="UserName" Type="String" />
                    <asp:Parameter Name="HasAccess" Type="String" />
                    <asp:Parameter Name="ApplicationDefinitionmainkey" Type="Byte" />
                    <asp:Parameter Name="SortOrder" Type="Int32" />
                    <asp:Parameter Name="MainKey" Type="Int16" />
                </UpdateParameters>
            </asp:SqlDataSource>
+1
source

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


All Articles