Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now