ASP.net Update problem can't be solved

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
I can't issue an update command on anything. From a GridView, from a DetailsView, nothing.

It just doesn't work. INSERT and DELETE are both fine. No one on the official ASP.net forum can work it out either.

Here's the error:

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: CodeName, CodeDescription, CodeType, CodeOwner, original_CodeID.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'Update' that has parameters: CodeName, CodeDescription, CodeType, CodeOwner, original_CodeID.

Here's the auto-generated update command being used in the TableAdapter:

Code:
UPDATE    Codes
SET              CodeName = @CodeName, CodeDescription = @CodeDescription, CodeType = @CodeType, CodeOwner = @CodeOwner
WHERE     (CodeID = @Original_CodeID)

Here's the ObjectDataSource code:

Code:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"
        InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetCodesByCodeID"
        TypeName="ManHoursTableAdapters.CodesTableAdapter" UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="Original_CodeID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="CodeName" Type="String" />
            <asp:Parameter Name="CodeDescription" Type="String" />
            <asp:Parameter Name="CodeType" Type="String" />
            <asp:Parameter Name="CodeOwner" Type="String" />
            <asp:Parameter Name="Original_CodeID" Type="Int32" />
            <asp:Parameter Name="CodeID" Type="Int32" />
        </UpdateParameters>
 
Last edited:
Probably wrong but:

Error is showing showing "ObjectDataSource 'ObjectDataSource2'" and the objectDataSource control has ID="ObjectDataSource1"

so something somewhere is referring to ObjectDataSource2 when it should be 1?
 
To both of you, if this isn't sorted:

Right click on the table adapter, click configure, advanced options, uncheck the 'Refresh the data table' option. Then save everything and it should work.


Mick.
 
To both of you, if this isn't sorted:

Right click on the table adapter, click configure, advanced options, uncheck the 'Refresh the data table' option. Then save everything and it should work.


Mick.

Haven't tried that. But what was well documented was you need to make the primary key in the GridView readonly=false. The problem is you have hide the key because a user might try and update it. Apparently this bug has been noted by Microsoft and they are not going to sort until VS 2008. Although, something weird happened today I created a new project and tried to recreate the problem but everything worked fine even when the readonly was set to true.

What implication does unchecking the Refresh the data table option have, do you know?
 
What implication does unchecking the Refresh the data table option have, do you know?
It shouldn't have any really, unless you're relying on identity of any inserts being returned. Get round that by doing any inserts where you need to find the inserted ID as stored procuedures with output parameters.
 
Back
Top Bottom