FIX - DataSet Error "Could not find a non generic method"

Rate It (1)

Last post 07-22-2008 5:26 AM by libsta. 37 replies.

Sort Posts:

  • FIX - DataSet Error "Could not find a non generic method"

    03-06-2006, 1:48 AM
    • Loading...
    • amensi
    • Joined on 02-13-2006, 7:43 PM
    • Canada
    • Posts 402

    Hi everyone.

    After dealing with this error for 2 weeks i finnally found the fix for it. First of all the error is caused by a "not found" parameters that looks like this: original_PrimaryKey. This is correct if you use optimistic concurrency or if your primary key is updatable.

    In order to correct this problem, got to the .aspx page with the ObjectDataSource that is causing the error, click on source (not the code beside) and locate the ObjectDataSource tag. It should look like this:

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"

    InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"

    TypeName="PaintingsTableAdapters.proc_PaintingsLoadAllTableAdapter" UpdateMethod="Update">

     

    The bold section represent the problematic section. Modify the "OldValuesParameterFormatString" value from "original_{0}" to "{0}". Et voilà !!!

    No more "Could not find a non-generic...." error. 

    Hope it helps you guys.

     

    p.s.: I am using Visual Studio 2005 Professional Version 8.0.50727.42 (RTM-050727-4200) Is there a more current version that my office should upgrade to or this one is ok? 



    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: FIX - DataSet Error "Could not find a non generic method"

    03-10-2006, 8:57 AM
    • Loading...
    • heochen
    • Joined on 03-10-2006, 1:55 PM
    • Posts 1

    It's great post. Thanks a lot. Literaturally it saves my "life"Big Smile [:D]

  • Re: FIX - DataSet Error "Could not find a non generic method"

    03-21-2006, 2:51 PM
    • Loading...
    • rmcquillen1
    • Joined on 03-21-2006, 7:50 PM
    • Posts 7

    I tried this fix.... and got a new error:

    Value cannot be null.
    Parameter name: Original_Item

  • Re: FIX - DataSet Error "Could not find a non generic method"

    03-28-2006, 12:10 PM
    • Loading...
    • mcrosmar
    • Joined on 02-28-2006, 4:54 PM
    • Athens, Greece
    • Posts 3
    Thank you very much amensi. Great post!!!!
  • Re: FIX - DataSet Error "Could not find a non generic method"

    04-04-2006, 2:46 PM
    • Loading...
    • Bubba.NET
    • Joined on 03-28-2006, 9:36 PM
    • Posts 11

    Perfect.  Works GREAT!  Thanks so much.

  • Re: FIX - DataSet Error "Could not find a non generic method"

    04-10-2006, 12:24 PM
    rmcquillen1:

    I tried this fix.... and got a new error:

    Value cannot be null.
    Parameter name: Original_Item

    Yup, me too!

  • Re: FIX - DataSet Error "Could not find a non generic method"

    05-04-2006, 4:57 PM
    • Loading...
    • ctut
    • Joined on 11-25-2003, 1:19 AM
    • Seattle
    • Posts 5
    The root of the problem has to do with the TableAdapter and its configuration wizard within the DataSet.xsd.

    By default, Visual Studio will enable the "Refresh the data table" option on the "Advanced Options" dialog accessible via a button in the lower left corner of the "Enter a SQL Statement" page of the TableAdapter Configuration Wizard.  If the "Refresh the data table" checkbox is checked, it will append a SELECT statement to the end of the UPDATE and INSERT statements to "retrieve identity column values, default values, and other values calculated by the database" of the row that was just updated.  To do this, it needs the "<PKField>" in addition to the "original_<PKField>" to be sent from the DataGrid control .  When the column property for the primary key is set to ReadOnly = True, the DataGrid will not include the "<PKField>" in its Parameters collection during the Update method call.  (note: <PKField> is the field name of your primary key as in "ID", or "original_ID")

    When ever we Update from the DataGrid, the "original_<PKField>" will be sent.  This is good.  It's the additional requirement of sending the "<PKField>" for the additional SELECT statement at the end of the Update query that is messing up our DataGrid's functionality.

    In other words, if the DataGrid is bound to the methods in the TableAdapter via an ObjectDataSource, and if the primary key column of the DataGrid is set ReadOnly=True, the DataGrid control will not pass the primary key to the Update and Insert methods of the TableAdapter even though those methods require it.  Instead, it will only include the "original_<PKField>"which it will use to locate the correct record to update.

    Disabling the "Refresh the data table" checkbox on the "Advanced Options" dialog during configuration of the TableAdapter makes the most sense to me and has the least impact on design and functionality while still allowing the IDE to generate most of the code.

    Some people have suggested changing the OldValuesParameterFormatString of the ObjectDataSource from "original_{0}" to simply "{0}", but this then causes the "original_<PKFieldName>" (i.e. "original_ID"), which is still there in the parameters collection of the ObjectDataSource, to never be initialized (i.e. null will be passed in the Parameters collection during the Update and Insert) by the GridView, resulting in the "Value cannot be null" error if your field cannot be null.  Some people benifited from the OldValuesParameterFormatString fix, but I believe it was because their fields could be null.

    Ctut
    geektweak.com
  • Re: FIX - DataSet Error "Could not find a non generic method"

    05-05-2006, 10:59 AM
    • Loading...
    • amensi
    • Joined on 02-13-2006, 7:43 PM
    • Canada
    • Posts 402
    Are you guys including this parameter in your grid... To do an update you need the PrimaryKey to be in the grid.


    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: FIX - DataSet Error "Could not find a non generic method"

    05-06-2006, 10:39 PM
    • Loading...
    • ctut
    • Joined on 11-25-2003, 1:19 AM
    • Seattle
    • Posts 5
    Yes, you'll need to have the ID included in the Grid, but set its visibility to hidden if you don't want to see it.  The Grid needs it when sending the original primary key value back to the table adapter.

    Ctut
    geektweak.com
  • Re: FIX - DataSet Error "Could not find a non generic method"

    06-27-2006, 6:33 PM
    • Loading...
    • NHustak
    • Joined on 10-29-2005, 12:51 PM
    • Posts 61

    Well it's great you found a fix.  What I'm about tired of is the useless databinding.  Two versions and it's still a joke.  You can't REALLY do visual databinding with VS2005.   I mean, sure if you like to hand work your code, which means you better remember what you did when you come back to modify it. 

    Basically, they still don't have it right.   Some interesting attempts, but things like connection strings you can't swap at runtime (Datasets), ObjectDatasource doesn't really work with wizard generated strongly typed datasets,  the dataset wizard can't handle temp tables in stored procedures...

    The list goes on and on.  Did someone actually try to write a real world application with the visual designer before this thing made it out the door? Obviously not.

    Sorry guys I'm just disgusted with the amount of time I've wasted on this.   Delphi still kicks VS 2005's butt - and it shouldn't.  And please don't try to tell me it works.  Just do a search on ObjectDataSource and watch all the work arounds that fall out.   If you don't mind handcoding all your database access, yeah it works great. 

    Regards,

    Nick H

    Regards,
    Nick H
    -------------------------------------------------
    You should only get points for posting if someone else flags your post useful. The current formula encourages people to post useless replies which cloud the threads.
  • Re: FIX - DataSet Error "Could not find a non generic method"

    06-27-2006, 9:57 PM
    • Loading...
    • NHustak
    • Joined on 10-29-2005, 12:51 PM
    • Posts 61

    Well and now suddenly it starts working - my objectdatasources are now saving data without the error.  No idea why.  I recreated everything just in case something was corrupt.

    So cool - half what I said still applies, but at least the databinding seems to be working.   I was wrong on that. 8)

    Regards,

    Nick H

    Regards,
    Nick H
    -------------------------------------------------
    You should only get points for posting if someone else flags your post useful. The current formula encourages people to post useless replies which cloud the threads.
  • Re: FIX - DataSet Error "Could not find a non generic method"

    07-19-2006, 3:19 PM
    • Loading...
    • blarggstar
    • Joined on 06-22-2006, 6:54 PM
    • Medford, OR
    • Posts 7

    I am also getting the "Could not find a non generic method" error, but the fix for my end was adding a non-generic method containing the exact parameters being passed.

     

     

  • Re: FIX - DataSet Error "Could not find a non generic method"

    08-04-2006, 4:41 PM
    • Loading...
    • JaiKirdatt
    • Joined on 01-28-2003, 5:48 AM
    • Posts 87
    This is my object data source which returns a data view

    <asp:ObjectDataSource OldValuesParameterFormatString="original_{0}" ID="odsIndustryDDL" runat="server" TypeName="Industry" SelectMethod="GetAllIndustriesForDDL()"></asp:ObjectDataSource>   

    This is my drop down list

    <asp:DropDownList ID="ddlIndustry" runat="server" DataSourceID="odsIndustryDDL" DataTextField="industry_descr" DataValueField="industry_id"></asp:DropDownList>

    Don't know what is wrong.

    Also I do not want to add a update command to my object data source. I do not really need to add OldValuesParameterFormatString either as i will not be updating the grid.

    any help is appreciated.

    Thanks
    you are not that powerful anniken. Well I should be someday I will be the most powerful Jedi in the world.
  • Re: FIX - DataSet Error "Could not find a non generic method"

    11-22-2006, 10:37 PM
    • Loading...
    • TheSnide
    • Joined on 11-23-2006, 2:35 AM
    • Posts 1

    For anyone still searching for a solution to "non-generic method" using ObjectDataSource error.

    Your problem may be compounded because of a space in the field name for the primary key.

     

    Removing the space and changing the OldValuesParameterFormatString from “original_{0}” to “{0}” worked for me.

     

    I hope it helps.

     

  • Re: FIX - DataSet Error "Could not find a non generic method"

    11-23-2006, 7:47 AM

    Cool post ! but sadly this is only one of the reasons on why this error comes. This is not a fool proof solution for the error. Sad

Page 1 of 3 (38 items) 1 2 3 Next >