Geeks With Blogs

News My Blog has been moved to https://mfreidge.wordpress.com
Michael Freidgeim's Blog My Blog has been moved to https://mfreidge.wordpress.com

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 on Thursday, March 1, 2007 6:58 PM ASP.NET | Back to top


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

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting 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.
Left by Steve Maczko on Mar 30, 2007 4:57 AM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting 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.
Left by Michael Freidgeim on Mar 30, 2007 11:22 AM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting Gravatar...
Is it just me, or is this STILL a problem in VWDE 2008??!?!
Left by Stan on Dec 02, 2007 12:26 AM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting Gravatar...
I haven't tried VS 2008 yet.
Left by Michael Freidgeim on Dec 02, 2007 8:45 AM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting Gravatar...
@Stan - Yes, this is STILL a problem in in VS 2008.
Left by J on Dec 15, 2007 11:12 PM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting 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.

Left by M.R. on Jan 27, 2008 7:12 PM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting 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.
Left by Patrik on Feb 11, 2009 2:44 AM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting 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.
Left by Patrik on Feb 11, 2009 3:26 AM

# re: Why we are getting ObjectDataSource: could not find a non-generic method 'Update'.
Requesting 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.
Left by Daniel on Sep 29, 2009 8:24 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net