ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Insert' that has parameters

Same problem 99% of all Object programmers in VS2005 are having when using Insert and XSD's.

 I have a DETAILS VIEW (not a gridview) for INSERTING records into a database.  XSD has been built with ONE stored procedure added to it (thought I'd narrow it down).  The spInsertRecord (for example) is connected to the INSERT dropdown on the datasource and the SELECT procedure (of course, we HAVE to have one of those or you jsut don't get the "next" button in the wonderful wizard of MS) set to CreateObjRef (because I've already tried creating a SP just for this cause and it didn't work...anyhoo).

 I type in data and pftp!  doesn't work.

 The first person that say, "oh, well, just change Original_{0} to {0}" is going to get their bloody head lopped off!  THAT DOESN'T WORK!

I've been dealing with this since last week.  It should be as simple as what I've explained.  DetailsView in DefaultMode Insert, XSD with Insert stored proc, connect via ObjectDataSource.

I think I'll go back to hard coding it like some others here.  Or, use dreamweaver.

0
aengle
2/4/2008 6:24:11 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

6 Replies
620 Views

Similar Articles

[PageSpeed] 14

Am I not understanding what you want? This worked just fine for Northwind.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DetailViewTestODS.aspx.cs" Inherits="DetailViewTestODS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ObjectDataSource ID="odsCategories" runat="server" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetData" TypeName="CategoriesTableAdapters.getCategoriesTableAdapter">
            <InsertParameters>
                <asp:Parameter Name="categoryName" Type="String" />
                <asp:Parameter Name="description" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
   
    </div>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="CategoryID"
            DataSourceID="odsCategories" Height="50px" Width="125px">
            <Fields>
                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
                    ReadOnly="True" SortExpression="CategoryID" />
                <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
    </form>
</body>
</html>
 


Please Mark As Answer posts that helped you.

"If we learn from our mistakes, I should be brilliant by now."


MCTS - .NET Framework 2.0: Web Applications
0
nikki_doer_of_things
2/4/2008 7:49:37 PM

1. Create a Stored Procedure and call it InsertData.

2.  Create an XSD file with that Stored Proc in it.

3.  Create a Details View, set up an ObjectDataSource, point it to the ONLY thing from your XSD (this assumes you built it and have the DLL and have set a reference), the stored procedure created in Step 1.  Set that as your INSERT source, set the SELECT source as CreateObjRef (as explained), click next and finish.

 It doesn't work.

0
aengle
2/4/2008 7:58:18 PM

So you want to only insert with a details view, right? You do NOT want to select any records? Am I understanding that?

I don't even have an option to create an XSD without specifying a select. 

To get a detail view using an objectdatasource that has nothing but insert, and it only inserts, this worked fine.

    <form id="form1" runat="server">
    <div>
        <asp:ObjectDataSource ID="odsCategories" runat="server" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
            TypeName="CategoriesTableAdapters.getCategoriesTableAdapter" >
            <InsertParameters>
                <asp:Parameter Name="categoryName" Type="String" />
                <asp:Parameter Name="description" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
   
    </div>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="CategoryID"
            DataSourceID="odsCategories" Height="50px" Width="125px" DefaultMode="Insert">           
            <Fields>
                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
                    ReadOnly="True" SortExpression="CategoryID" />
                <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
    </form>


Please Mark As Answer posts that helped you.

"If we learn from our mistakes, I should be brilliant by now."


MCTS - .NET Framework 2.0: Web Applications
0
nikki_doer_of_things
2/4/2008 9:24:23 PM

I recreated the XSD with just the table I needed and LET Microsoft's little wizard create all four stored procedures for me.  Then I recreated the ASCX page with the details views.  It works...BUT, it's not a multi-tiered system.  I need to tweak it out and see what happens.

 The ONLY 2 differences between my Stored Procedures and Microsofts are:  MS puts [..] around all my field (column) names, and at the end of the INSERT procedure, there is a SELECT statement.  (???).

 I have modified my stored procedures to match the old ones.  I'll mark this as solved, although I'm still not quite sure what solved it or where the problem was.

I guess it boils down to, don't think you can design your own stored procs and connect them to your controls.  Obviously some code will be missed.

0
aengle
2/5/2008 2:57:59 PM

I created my own stored procedures and connected them to the controls.

I created the stored procedures in SQL Server.

I used the xsd wizard to create typed datasets and set the selects, inserts, and updates to the appropriate stored procs for each.

I connected the object data sources to those typed datasets using the wizard.

I connected gridviews, formviews, and detailviews to those object data sources.

So while I'm not sure where your code went wrong, since it's hard to describe using the wizards, it CAN be done. I've created an entire 3 tier system doing it. 


Please Mark As Answer posts that helped you.

"If we learn from our mistakes, I should be brilliant by now."


MCTS - .NET Framework 2.0: Web Applications
0
nikki_doer_of_things
2/5/2008 7:10:40 PM

Well, I'll try it again.  At the end of your INSERT procedure, do you have a SELECT statement?  MS, like I mentioned, generated one for me.

On the bright side - it's a lot quicker forcing MS to generate 4 generic stored procedures than hand coding them.  Of course, I have to modify most with my own parameters, but hey, I got the shell.

0
aengle
2/5/2008 7:24:21 PM
Reply:

Web resources about - ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Insert' that has parameters - asp.net.object-datasource

Resources last updated: 12/13/2015 4:40:26 AM