[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method

Posted on 2011-03-09
1
Medium Priority
?
713 Views
Last Modified: 2012-05-11
Hi EE,

I have code below which is generating following error msg. PLS HELP!!

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'UpdateSubPublicationDetails' that has parameters: ContactName, ContactPhone, ContactEmail, ContactCity, ContactNotes, HL, PR, Disable, Sectors, PubID, Format, PublicID, fmt, PubContactID.


Thank U!!!
[index.aspx]
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" 
        DataSourceID="ObjectDataSource1" EnableModelValidation="True" 
        AutoGenerateRows="False" DataKeyNames="PubContactID">
        <Fields>
            <asp:BoundField DataField="PubContactID" HeaderText="PubContactID" 
                InsertVisible="False" ReadOnly="True" SortExpression="PubContactID" />
            <asp:BoundField DataField="ContactName" HeaderText="ContactName" 
                SortExpression="ContactName" />
            <asp:BoundField DataField="ContactPhone" HeaderText="ContactPhone" 
                SortExpression="ContactPhone" />
            <asp:BoundField DataField="ContactEmail" HeaderText="ContactEmail" 
                SortExpression="ContactEmail" />
            <asp:BoundField DataField="ContactCity" HeaderText="ContactCity" 
                SortExpression="ContactCity" />
            <asp:BoundField DataField="ContactNotes" HeaderText="ContactNotes" 
                SortExpression="ContactNotes" />
            <asp:BoundField DataField="PublicID" HeaderText="PublicID" 
                SortExpression="PublicID" />            
            <asp:BoundField DataField="Sectors" HeaderText="Sectors" 
                SortExpression="Sectors" />
            <asp:BoundField DataField="fmt" HeaderText="fmt" SortExpression="fmt" />            
            <asp:CommandField ShowEditButton="True" />
        </Fields>
    </asp:DetailsView>

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        SelectMethod="GetSubPublicationDetails" TypeName="DataAccess" 
        UpdateMethod="UpdateSubPublicationDetails" 
        onupdated="ObjectDataSource1_Updated">
        <SelectParameters>
            <asp:QueryStringParameter Name="PubID" QueryStringField="id" Type="Int32" 
                DefaultValue="" />
            <asp:QueryStringParameter DefaultValue="eng" Name="lang" 
                QueryStringField="lang" Type="String" />
        </SelectParameters>

        <UpdateParameters>
            <asp:Parameter Name="ContactName" Type="String" />
            <asp:Parameter Name="ContactPhone" Type="String" />
            <asp:Parameter Name="ContactEmail" Type="String" />
            <asp:Parameter Name="ContactCity" Type="String" />
            <asp:Parameter Name="ContactNotes" Type="String" />            
            <asp:Parameter Name="HL" Type="Int32" DefaultValue="0" />
            <asp:Parameter Name="PR" Type="Int32" DefaultValue="1" />
            <asp:Parameter Name="Disable" Type="Int32" DefaultValue="0" />
            <asp:Parameter Name="Sectors" Type="String" />
            <asp:Parameter Name="PubID" Type="Int32" />   
            <asp:Parameter Name="PubContactID" Type="Int32" />                     
            <asp:Parameter Name="Format" Type="String" />   
        </UpdateParameters>
    </asp:ObjectDataSource>

[DataAccess.cs]
public static int UpdateSubPublicationDetails(string ContactName,string ContactPhone,string ContactEmail, string ContactCity, string ContactNotes,int HL, int PR, int Disable, string Sectors, int PubID, int PubContactID, string Format) {
        int rowAffect = 0;
        using (SqlConnection con = new SqlConnection(Settings.ConnectionStringACN))
        {
            con.Open();
            string SQL = "spSvePubContact";
            using (SqlCommand cmd = new SqlCommand(SQL, con))
            {
                cmd.Parameters.Add("@ContactName",SqlDbType.VarChar).Value=ContactName;
                cmd.Parameters.Add("@ContactPhone", SqlDbType.VarChar).Value = ContactPhone;
                cmd.Parameters.Add("@ContactEmail", SqlDbType.VarChar).Value = ContactEmail;
                cmd.Parameters.Add("@ContactCity", SqlDbType.VarChar).Value = ContactCity;
                cmd.Parameters.Add("@ContactNotes", SqlDbType.VarChar).Value = ContactNotes;
                cmd.Parameters.Add("@HL", SqlDbType.Int).Value = 0;
                cmd.Parameters.Add("@PR", SqlDbType.Int).Value = 1;
                cmd.Parameters.Add("@Disable", SqlDbType.Int).Value = 0;
                cmd.Parameters.Add("@Sectors", SqlDbType.VarChar).Value = Sectors;
                cmd.Parameters.Add("@PubID", SqlDbType.Int).Value = PubID;
                cmd.Parameters.Add("@PubContactID", SqlDbType.Int).Value = PubContactID;
                cmd.Parameters.Add("@Format", SqlDbType.VarChar).Value = Format;
                cmd.CommandType = CommandType.StoredProcedure;
                rowAffect = cmd.ExecuteNonQuery();				
            }
            con.Close();
        }
        return rowAffect;
    }

Open in new window

0
Comment
Question by:saloj
1 Comment
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 35089523
This is occurring because parameters automatically get created for the bound controls based on the datafield value you must ensure the parameter names match the datafield values used on the bound controls.

More info : http://msdn.microsoft.com/en-us/library/57hkzhy5.aspx
http://msdn.microsoft.com/en-us/library/ms228051.aspx
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Integration Management Part 2
Loops Section Overview
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question