Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

I've hit the same problem again. I've already wrote 2 posts  about the error "Exception Details: System.InvalidOperationException: ObjectDataSource 'ods' could not find a non-generic method 'Update' that has parameters: ...." ( Editable GridView with ObjectDatasource and Update method parameters. and Some workaround for ObjectDataSource: could not find a non-generic method '...' .) And these posts are the most popular in my blog according to views statistics. Not because they are very useful - just because topic is very hot - a lot of people experience the same problem.

I've read again Brady Gaster's detailed post and understood, that his sample very similar to mine. I also have table with integer IDENTITY primary key and 2 nvarchar columns. Ive used DataAdapter wizard to generate insert/update/delete methods without generating Stored Procedures and without support for optimistic cuncurrency. And I am using DetailsView instead of editable GridView.

I believe that the root of the problem is in the wrong assumption which parameters should have default Update method.
Just follow Brady's example the function is
Update(String Firstname, String Lastname, int32 Original_PersonId, int32 PersonId)  

How often developer needs to update IDENTITY PRIMARY KEY? If not, why we need the last parameter? If the generated Update will have just 3 parameters(Firstname, Lastname,  Original_PersonId),GridView and DetailView will work as expected.

I've  raised suggestion to MS "Generated default Update method in DataTableAdapter in a typed DataSet  shouuld not update primary key". Please rate/validate it.

UPDATE: Hurray! Posted by Microsoft on 5/05/2007: "We have fixed the issue with an additional update function.
The fix will be available in the next VS release."
 

posted @ Thursday, March 01, 2007 6:58 PM

Print

Comments on this entry:

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

Left by Steve Maczko at 3/30/2007 4:57 AM
Gravatar
I'm working with a situation where i'm using a preexisting sproc.

In that case I am going to have to pass the identity primary key as a paramiter--to use in the WHERE clause.

Can't imagine any generated code doing anything different! If so, I'd like to see an explanation.

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

Left by Michael Freidgeim at 3/30/2007 11:22 AM
Gravatar
Steve,
VS Designer generated SPs expect primary key to be passed twice- as a original primary key and as updated value. They coded for rare case of updating primary key and made it as the only option.

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

Left by Stan at 12/2/2007 12:26 AM
Gravatar
Is it just me, or is this STILL a problem in VWDE 2008??!?!

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

Left by Michael Freidgeim at 12/2/2007 8:45 AM
Gravatar
I haven't tried VS 2008 yet.

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

Left by J at 12/15/2007 11:12 PM
Gravatar
@Stan - Yes, this is STILL a problem in in VS 2008.

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.

Left by M.R. at 1/27/2008 7:12 PM
Gravatar
We should have known MS's definition of the phrase "next version" did not mean Visual Studio 2008 because, as shocking as it may sound, this problem still exists!!! I love when the tools we have to do our jobs, dont help us do our jobs. Makes for some veeeerrryyy long days and weekends.

Your comment:



 (will not be displayed)


 
 
 
Please add 4 and 6 and type the answer here:
 

Live Comment Preview:

 
«September»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011