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

Hi

am getting this error when am trying to insert new record in Details View
 
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'insertdata' that has parameters 
 
The data source for the details view is objectdatasoure which configured on class located in app_code folder
 
the class contain 2 methods one for selecting and one for inserting  ,
 
 
please anyone can help to solve this problem
0
the_saint
5/6/2007 2:37:03 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

16 Replies
910 Views

Similar Articles

[PageSpeed] 58

1) Did you define the method that will handle the inserting for the ObjectDataSource control? (posting the code from the .aspx page might help)

2) If you have defined it, what parameters does that method  (in your App_Code folder) take? (Usually you pass a object to it)

3) If you are passing an object to the inserting method (in your App_Code folder) is that object defined as a parameter in your ObjectDataSource?



SilverlightDesktop.net

A framework that allows you to dynamically load Silverlight modules into resizable draggable windows.
0
adefwebserver
5/6/2007 2:54:28 PM

i made small exmple !! inserting data on  table "test1" have one column on  the name of the cloum is trans_jd

 the name of insert procedure "test" with one parameter v_trans_id .  

 

 the ASP code :

 <div>

&nbsp;<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="test"

SelectMethod="Gettest" TypeName="BankDataAccess" DeleteMethod="deletetest">

<InsertParameters>

<asp:ControlParameter ControlID="DetailsView1" Name="v_trans_id" PropertyName="SelectedValue"

Type="Int32" />

</InsertParameters>

<DeleteParameters>

<asp:Parameter Name="v_trans_id" Type="Int32" />

</DeleteParameters>

</asp:ObjectDataSource>

<asp:Button ID="Button1" runat="server" Style="z-index: 100; left: 29px; position: absolute;

top: 375px"

Text="Button" />

<asp:DetailsView ID="DetailsView1" runat="server" CellPadding="4" DataSourceID="ObjectDataSource1"

ForeColor="#333333" GridLines="None" Height="213px" Style="z-index: 102; left: 54px;

position: absolute; top: 136px"

Width="365px">

<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<CommandRowStyle BackColor="#C5BBAF" Font-Bold="True" />

<EditRowStyle BackColor="#7C6F57" />

<RowStyle BackColor="#E3EAEB" />

<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />

<Fields>

<asp:CommandField ShowDeleteButton="True" ShowInsertButton="True" />

</Fields>

<FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True" />

<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="White" />

</asp:DetailsView>

 

</div>

</form>

</

body>

</

html>

 

0
the_saint
5/7/2007 1:13:20 PM

sorry this is the correct ASP

 

<

div>

&nbsp; &nbsp;&nbsp;

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

InsertMethod="test" SelectMethod="Gettest" TypeName="BankDataAccess">

<DeleteParameters>

<asp:Parameter Name="v_trans_id" Type="Int32" />

</DeleteParameters>

<InsertParameters>

<asp:Parameter Name="v_trans_id" Type="Int32" />

</InsertParameters>

</asp:ObjectDataSource>

<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="ObjectDataSource1"

Height="50px" Style="z-index: 100; left: 128px; position: absolute; top: 202px"

Width="125px">

<Fields>

<asp:CommandField ShowDeleteButton="True" ShowInsertButton="True" />

</Fields>

</asp:DetailsView>

 

</div>

</form>

</

body>

</

html>
0
the_saint
5/7/2007 1:21:23 PM

still getting this Error Message:

 

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'test' that has parameters: v_trans_id, TRANS_ID.

0
the_saint
5/7/2007 1:23:30 PM

Do you have a class called "BankDataAccess" that has a method called "test"? If so what parameters does it take? (what is it's method signature).

If you do not have a class called "BankDataAccess" that has a method called "test" then you will need to create one to handle the insert. The way you currently have the ObjectDataSource control coded shows that the test method should accept a v_trans_id (integer).



SilverlightDesktop.net

A framework that allows you to dynamically load Silverlight modules into resizable draggable windows.
0
adefwebserver
5/7/2007 1:27:32 PM
the_saint:

still getting this Error Message:

 

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'test' that has parameters: v_trans_id, TRANS_ID.

Do you have a method called test? Does it take the two parameters?



SilverlightDesktop.net

A framework that allows you to dynamically load Silverlight modules into resizable draggable windows.
0
adefwebserver
5/7/2007 1:34:11 PM

yes .. i have it in App_Code folder

with the follwing code:

Public

Class BankDataAccess

Public Sub test(ByVal v_trans_id As Integer)

Dim Oraconn As New OracleConnection

Oraconn = ConnectionManager.getOracleConnection()

Dim Sql As String = "test"

Dim sqlcommand As New OracleCommand(Sql, Oraconn)

sqlcommand.CommandType = Data.CommandType.StoredProcedure

sqlcommand.Parameters.Add(

"v_trans_id", OracleType.Number).Value = v_trans_id

sqlcommand.ExecuteNonQuery()

Oraconn.Dispose()

End Sub

Public Shared Function Gettest()

Dim Sql As String = "SELECT * FROM test1"

Dim Oraconn As New OracleConnection

Oraconn = ConnectionManager.getOracleConnection()

Dim sqlcommand As New OracleCommand(Sql, Oraconn)

sqlcommand.CommandType = Data.CommandType.Text

Dim reader As OracleDataReader = sqlcommand.ExecuteReader(Data.CommandBehavior.CloseConnection)

Return reader

End Function

Public Sub deletetest(ByVal v_trans_id As Integer)

Dim Oraconne As New OracleConnection

oraconne = ConnectionManager.getOracleConnection()

Dim Sql As String = "deletetest"

Dim sqlcommand As New OracleCommand(Sql, Oraconne)

sqlcommand.CommandType = Data.CommandType.StoredProcedure

sqlcommand.Parameters.Add(

"v_trans_id", OracleType.Number).Value = v_trans_id

sqlcommand.ExecuteNonQuery()

End Sub

End

Class
0
the_saint
5/7/2007 1:40:51 PM

The ObjectDataSouce control wants to pass two parameters. It wants to also pass "TRANS_ID". Can you tell if there is any code on the page that is attempting to pass that parameter?



SilverlightDesktop.net

A framework that allows you to dynamically load Silverlight modules into resizable draggable windows.
0
adefwebserver
5/7/2007 1:48:28 PM

as i show you in my ASP code,, alli have i my webpage 2 object ., one object data source and the other one is DetailsView

 nothing more , even when i want to delete a record am getting the same error message

0
the_saint
5/7/2007 1:54:12 PM

as i show you in my ASP code,, all i have in my webpage just 2 object ., the objectdatasource  and the other one is DetailsView

 nothing more , by the way even when i want to delete a record am getting the same error message

0
the_saint
5/7/2007 1:55:41 PM

as i show you in my ASP code,, all i have in my webpage just 2 object ., the objectdatasource  and the other one is DetailsView

 nothing more , by the way even when i want to delete a record am getting the same error message

0
the_saint
5/7/2007 1:56:50 PM

as i show you in my ASP code,, all i have in my webpage just 2 object ., the objectdatasource  and the other one is DetailsView

 nothing more , by the way even when i want to delete a record am getting the same error message

0
the_saint
5/7/2007 1:59:02 PM
I'm at a loss :(

SilverlightDesktop.net

A framework that allows you to dynamically load Silverlight modules into resizable draggable windows.
0
adefwebserver
5/7/2007 4:29:50 PM
no problem and thanks for your time >
0
the_saint
5/8/2007 11:50:58 AM
I am having the exact same problem. It is passing the insert parameter and the field name on the table for some reason. I am using the example northwind db with the 3 tier application tutorial and it works fine for products, i try and do the same thing with an employee and it bombs out. 

Rich -- select * from pubs
0
Rcap238
5/8/2007 5:28:30 PM

I had to change the parameter names of the my procedure to the same names the fields where on the database and it fixed the issue. No idea why the behavior acts like this but here is my code

 

aspx page

<asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False"
        DataKeyNames="EmployeeID" DataSourceID="ObjectDataSource2" DefaultMode="Insert"
        Height="50px" Width="125px">
        <Fields>
            <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
            <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" InsertMethod="AddUnit"
        SelectMethod="GetEmployees"  TypeName="EmployeesBLL" OldValuesParameterFormatString="original_{0}">
        <InsertParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>

 

Database table has FirstName and LastName as field names.

 

Here is the procedure in the BLL class

   [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
    public bool AddUnit(string LastName, string FirstName)
    {
        // Create a new EmployeeRow instance
        Northwind.EmployeesDataTable employees = new Northwind.EmployeesDataTable();
        Northwind.EmployeesRow employee = employees.NewEmployeesRow();


        employee.FirstName = FirstName;
        employee.LastName = LastName;

        // Add the new Employee
        employees.AddEmployeesRow(employee);
        int rowsAffected = Adapter.Update(employees);

        // Return true if precisely one row was inserted,
        // otherwise false
        return rowsAffected == 1;

    }

 

 

 

 

 


Rich -- select * from pubs
0
Rcap238
5/8/2007 6:16:18 PM
Reply:

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

Resources last updated: 12/19/2015 11:22:43 AM