Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-09-30
10
Medium Priority
?
1,810 Views
Last Modified: 2013-12-17
Good morning experts,

I am having trouble updating data in a gridview..please find attached my code..I get the following error:

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'UpdateSponsorUser' that has parameters: sname, semail, webaddress, sdesc, tel, address, original_sponsorid

I dont know where it is getting original_sponsorid ??? Please help me identify the error as I am well after my deadline, and cant do these sleepless nights much longer..
.aspx
 
<div class="content">
                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="sponsorid"
                                    DataSourceID="ObjectDataSource1">
                                    <Columns>
                                        <asp:BoundField DataField="sname" HeaderText="sname" SortExpression="sname" />
                                        <asp:BoundField DataField="semail" HeaderText="semail" SortExpression="semail" />
                                        <asp:BoundField DataField="webaddress" HeaderText="webaddress" SortExpression="webaddress" />
                                        <asp:BoundField DataField="sdesc" HeaderText="sdesc" SortExpression="sdesc" />
                                        <asp:BoundField DataField="tel" HeaderText="tel" SortExpression="tel" />
                                        <asp:BoundField DataField="address" HeaderText="address" SortExpression="address" />
                                        <asp:CommandField ShowEditButton="True" />
                                        <asp:BoundField DataField="sponsorid" HeaderText="sponsorid" InsertVisible="False"
                                            ReadOnly="True" SortExpression="sponsorid" Visible="False" />
                                    </Columns>
                       
                                </asp:GridView>
                                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
                                    SelectMethod="GetSponsorByType" TypeName="sponsorsBLL" UpdateMethod="UpdateSponsorUser">
                                    <SelectParameters>
                                        <asp:SessionParameter Name="sponsorid" SessionField="user" Type="Int32" />
                                    </SelectParameters>
                                    <UpdateParameters>
                                        <asp:Parameter Name="sname" Type="String" />
                                        <asp:Parameter Name="semail" Type="String" />
                                        <asp:Parameter Name="webaddress" Type="String" />
                                        <asp:Parameter Name="sdesc" Type="String" />
                                        <asp:Parameter Name="tel" Type="String" />
                                        <asp:Parameter Name="address" Type="String" />
                                        <asp:Parameter Name="sponsorid" Type="Int32" />
                                    </UpdateParameters>
                                    
                                </asp:ObjectDataSource>
                              
                            </div>
 
sponsorBLL.cs
 
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, false)]
    public propview.sponsorsDataTable UpdateSponsorUser(string sname, string semail, string webaddress, string sdesc, string tel, string address)
    {
        return UpdateSponsorUser(sname, semail, webaddress, sdesc, tel, address);
    }

Open in new window

0
Comment
Question by:kasonde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
10 Comments
 
LVL 10

Expert Comment

by:oxyoo
ID: 22604877
I think the problem is that In the gridview and the object data source you have specified sponsorid. but it is not specified in the UpdateSponsorUser in the sponsorBLL.cs.

<asp:BoundField DataField="sponsorid" HeaderText="sponsorid" InsertVisible="False"
                                            ReadOnly="True" SortExpression="sponsorid" Visible="False" />
                                    </Columns>

and in the data source...
<asp:Parameter Name="sponsorid" Type="Int32" />

but it is not present in the mehtod..
  UpdateSponsorUser(string sname, string semail, string webaddress, string sdesc, string tel, string address)



Good Luck!
0
 

Author Comment

by:kasonde
ID: 22606466
I added the sponsorid to the sponsor but still did not work..is the session sponsorid supposed to be present parameters for the update method?  I am trying to update a row of tables based on the session passed..e.g.update sname, semail, webaddres etc. WHERE sponsor.id = Session["sponsorid"]; thanks for your help
0
 
LVL 10

Expert Comment

by:oxyoo
ID: 22623119
Hi,

I am unsure about this but it seems as if it wants the sponsorid as a parameter to your UpdateSponsorUser.

But I'm only guessing here.

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, false)]
    public propview.sponsorsDataTable UpdateSponsorUser(string sname, string semail, string webaddress, string sdesc, string tel, string address)
    {
        return UpdateSponsorUser(sname, semail, webaddress, sdesc, tel, address, original_sponsorid);
    }

Open in new window

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:kasonde
ID: 22631940
That was a mistake I guess..the sponsor id is been passed as a session in the where clause e.g. WHERE id = Session["user"]..who do I include that in my DAL, or pls advise on how  I can pass session to the query for updating using the objectdatasource and gridview..Assistance much appreciated.
0
 
LVL 10

Expert Comment

by:oxyoo
ID: 22632311
I would not recommend you to use Session objects in the DAL, that is more of a UI thing. Doing so would mean that your DAL will need a System.Web(?) reference which I do not think is suitable for a DAL layer.

A better solution in my opinion is if you pass it along with your methods.

Just my 2c..
0
 

Author Comment

by:kasonde
ID: 22635000
can you show me an implementation or at least lead me in the right direction, how would I pass it along with my methods?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22640427
This is where you are getting that field name from:
OldValuesParameterFormatString="original_{0}"
0
 
LVL 10

Accepted Solution

by:
oxyoo earned 2000 total points
ID: 22640539
This would be one solution (there are always many when developing software :) )...

If you have 3 layers..
1. The UI; where Session["user"] lives
2. The Business layer; MyBusinessClass.DoAction(string user);
3. The DAL layer; MyDalClass.PerformDataAceesStuff(string user);

In this scenario, in the UI you would call MyBusinessClass.DoAction(Session["user"].ToString());
And in the Business layer, you would call DAL with MyDalClass.PerformDataAccessStuff(user);
Know you have the user details in the DAL.

There are other options as well, you might put it into the constructor.

Hope that helps.
Good Luck!
0
 

Author Closing Comment

by:kasonde
ID: 31501497
Thanks. simple straight to the point.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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