TableAdapter Update Error
ObjectDataSource 'RegionObject' could not find a non-generic method 'Update' that has parameters: RegionDescription, original_RegionID. Version Information: Alaa Bhr
Thanks
Software Developer
ObjectDataSource 'RegionObject' could not find a non-generic method 'Update' that has parameters: RegionDescription, original_RegionID. Version Information: Alaa Bhr
Thanks
Software Developer
cheers,
Paul June A. Domag
Is there some oddity with this April CPT version of visual web developer 2005 Express?
Any thoughts are appreciated.
thank you,
chuck
Could you provide steps to reproduce this behavior? That should make it easier to get a helpful response.
David Sceppa
Microsoft
1. create new dataset in the app_code folder, called interaction.xsd. (right-click on the app_code directory and select new...)
a. Step through the TableAdapter Configuration Wizard.
b. Select the data connection (ManagementConnection String (Web.config)
c. Create new stored procedures
d. sql statement "SELECT Interaction.* FROM Interaction
e. new stored procedure names: InteractionSelect_sp, InteractionInsert_sp, InteractionUpdate_sp, InteractionDelete_sp
f. Fill method: FillInteraction, Get method: GetInteraction
g. Checked Create methods to send updates directly...
h. I now have Interaction.xsd.
2. Create new content page (code in separate file (Visual Basic) and uses master page), called Interaction.aspx.
3. In Design view, drag an ObjectDataSource onto the page.
a. (Configure Data Source) Selected InteractionTableAdapters.InteractionSelect_spTableAdapter.
b. Select method: GetInteraction(), return...
c. Update method: Update(Nullable<INT32> iFirmID, ... (Each field in the Interaction table is listed, as well as "Original_iInteractionID, Int32".)
d. Insert method: Insert(Nullable(int32> iFirmID,...(again, each field in the Interaction table is listed.)
e. Delete method: Delete(Int32 Original_iTransactionID), returns Int32
4. Drag a Gridview object onto the page.
a. Choose Data Source - ObjectDataSource1 selected.
b. Select "Enable Editing" and "Enable Deleting" also for the Gridview.
5. ctl-F5, select the page from the page navigation. Data is pulled from the database and is correct. Click on the Edit link, click on the update link.
6. Get the non-generic method error.
What am I doing wrong? What step am I missing?
chuck
Best wishes,
chuck
Dear David,
Here are my process in details (all the details
)
1-Create new web site
2-Add App_Code folder
3-Add new DataSet under the App_Code folder
4-Add new DataAdapter
5-Select Region table "from Northwind"
6-Select Create new SP
7-Check Create method to send updates directly to database
8-Unchek FillData
9-Check GetData
10-Add GridView to the form
11-Choose <New DataSource> ObjectDataSource
12-Configure it as following:
- Select: GetRegions() returns RegionsDataTable
- Update: Update(Int32 RegionID, String RegionDescription, Int32 Original_RegionID), returns Int32
- Delete: Delete(Int32 Original_RegionID), returns Int32
13-Enable the GridView Editding, Deleting and Paging
14-Run the application
15-Try to Edit got:
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: RegionDescription, original_RegionID.
16-Try to Delete:
It delete Normaly
Best regards,
Hope this helps,
Bradley Millington
Web Platform and Tools Team, Microsoft
Just to elaborate on Bradley's post...to resolve the "could not find non-generic method" error when using a generated DataSet with the ObjectDataSource, you should to the following to modify the generated Update method on the tablenameDataAdapter in the DataSet (where tablename is the name of the table you're pulling from the database):
1. Open the DataSet in Visual Studio 2005 and highlight the tablenameDataAdapter title bar.
2. If you don't already have the Properties window open, press F4 to open it, and locate the UpdateCommand item.
3. Click the + sign next to UpdateCommand to expand the individual properties.
4. Edit the CommandText to remove the primary key column from the query.
This should resolve the mismatch between the DataAdapter and the data-bound control.
Bradley wrote:
The problem in this case is that your Update method takes three params: RegionID, RegionDescription, and Original_RegionID but only two params are passed to the data source by the data-bound control: RegionDescription and Original_RegionID. I suspect you need to set ReadOnly=false on the RegionID column in the GridView, so that a new value is passed to the data source for this column. Alternatively, if you do not want to support editing the primary key (RegionID), then alter your Update statement so that it does not expect this value. Hope this helps,
Bradley Millington
Web Platform and Tools Team, Microsoft
I think there is more to this problem than just a mismatch between parameters in ObjectDataSource and the TableAdapter. The ObjectDataSource is automatically adding on parameters. I am getting the following error:
ObjectDataSource 'odsIAF' could not find a non-generic method 'Update' that has parameters: Status, RecDivision, RecLocation, RecContact, RecAddress, RecPhone, RecFax, ProDivision, ProLocation, ProContact, ProAddress, ProPhone, ProFax, original_ID, ID, DateEntered.
Neither ID or DateEntered are defined in the TableAdapter's UpdateCommand CommandText or Parameters. They are not defined in the ObjectDataSource's UpdateParameters. They are being returned by the select. Something is causing them to be automatically tacked onto the end.
I also had to then go and edit my g_UpdateTable stored procedure to remove the extra column too.
Kevin
OnFocus
="this.blur();"change
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" SortExpression="EmployeeID" />
to
<
asp:TemplateField HeaderText="EmployeeID" SortExpression="EmployeeID"><EditItemTemplate><asp:TextBox ID="TextBox1" OnFocus="this.blur();" runat="server" Text='<%# Bind("EmployeeID") %>'></asp:TextBox></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EmployeeID") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("EmployeeID") %>'></asp:Label></ItemTemplate></asp:TemplateField>I followed the steps you suggested but I still got the error.
I noticed that under the UpdateCommand, there is a Parameters collection. I opened it and the primary key column is also defined there! I remove it and its working now. Thanks for pointing the right direction!