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.

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

Left by Patrik at 2/11/2009 2:44 AM
Gravatar
Yes I have the same problem in VS2008 I am trying to google a solution. I have stored procedures a gridview and a objectdatasource
I decided I wanted to use typed dataset. Its primarely the update method wich keeps inventing parameter methods or complaining over keys having null values ( do they dont). I think a have spent three days now of finding as solution that is acceptable.

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

Left by Patrik at 2/11/2009 3:26 AM
Gravatar
I got the update to work. The update stored procedure had a different name @InvoicenNr instead of @InvoiceNr. InvoiceNr is what it is called in the select stored procedure and everywhere else. This spelling mistake made the remove original{0} solution not to work. But I honestly think I should be able to call my params what I what. Luckily I am the star programmer and DBA in my one person project.

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

Left by Daniel at 9/29/2009 8:24 PM
Gravatar
2 weeks of struggling and I've finally got this down to an art using SELECT queries with joins.

The key is to build your SELECT statement with your UPDATE statement in mind. This means initially using a SELECT statement that doesn't use joins (I would not suggest messing with sub-queries in this inital statement, either).

STEPS
#1. Create your plain vanilla SELECT query using the standard table-adapter wizard. No joins allowed. Make sure you check "Create Insert/Update Statements..." in advanced options. Once that's done and your statements are created...

#2. Create your fancy SELECT statement with joins/sub-queries in the editor of your choice (I prefer Access because I can copy/paste the sql easily).

#3. Back in VS, Right click and select "Properties" on your tableadapter.

#4. In the Properties floaty, click the "+" sign next to SelectCommand.

#5. Paste your fancy SELECT statment into the CommandText box. You will be prompted to auto-generate the other statements. CLICK NO.

#6. I SAY AGAIN: CLICK NO.

This should give you a dataset with values that you can query against and perform updates on (as always, make sure you're not trying to update a foreign key value on another table in your dataset).

Happy head-banging. Good luck.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345