Solved

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

Posted on 2011-03-09
1
673 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 500 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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