vb.net ASP.NET ObjectDataSource 找不到具有参数的非泛型方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16641243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:39:09  来源:igfitidea点击:

ASP.NET ObjectDataSource could not find a non-generic method that has parameters

c#asp.netsqlvb.netobjectdatasource

提问by Diluen Cheong

I am using a FormView control on an ASP.Net page with an ObjectDataSource that is linked to a Business Tier component connected to stored procedures in the SQL Server. I am getting the ObjectDataSource could not be found error and I have made sure that all my components contain the parameters (and that they exist).

我在 ASP.Net 页面上使用 FormView 控件,其 ObjectDataSource 链接到连接到 SQL Server 中存储过程的业务层组件。我收到无法找到 ObjectDataSource 错误,并且我已确保我的所有组件都包含参数(并且它们存在)。

enter image description here

在此处输入图片说明

I can't figure out why it can't find the parameters even though they are there?

我不明白为什么它找不到参数,即使它们在那里?

Stored Procedure:

存储过程:

UPDATE [Anime_List] SET [Name] = @name, [AnimeImage] = @anime_image, [Synopsis] = @synopsis, [Type] = @type, [Episodes] = @episodes, [Genres] = @genres, [Rating] = @rating WHERE (([AnimeID] = @original_animeID));

Business Component:

业务组成:

[DataObjectMethod(DataObjectMethodType.Update)]
public static void UpdateAnimeList(string name, string anime_image, string synopsis, 
    string type, short episodes, string genres, decimal rating, int original_animeID,
    int animeID)
{
    animeList.AnimeListUpdateCommand(name, anime_image, synopsis, type, episodes,
        genres, rating, original_animeID, animeID);
}

Database Design:

数据库设计:

enter image description here

在此处输入图片说明

Table Adapter Configuration:

表适配器配置:

enter image description here

在此处输入图片说明

ASP.Net:

ASP.NET:

<asp:ObjectDataSource ID="AnimeDataSource" runat="server" DeleteMethod="DeleteAnimeTitle" InsertMethod="InsertAnimeList" OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllTitles" TypeName="Business.BAnimeList" UpdateMethod="UpdateAnimeList">
            <DeleteParameters>
                <asp:Parameter Name="original_animeID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="name" Type="String" />
                <asp:Parameter Name="anime_image" Type="String" />
                <asp:Parameter Name="synopsis" Type="String" />
                <asp:Parameter Name="type" Type="String" />
                <asp:Parameter Name="episodes" Type="Int16" />
                <asp:Parameter Name="genres" Type="String" />
                <asp:Parameter Name="rating" Type="Decimal" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="name" Type="String" />
                <asp:Parameter Name="anime_image" Type="String" />
                <asp:Parameter Name="synopsis" Type="String" />
                <asp:Parameter Name="type" Type="String" />
                <asp:Parameter Name="episodes" Type="Int16" />
                <asp:Parameter Name="genres" Type="String" />
                <asp:Parameter Name="rating" Type="Decimal" />
                <asp:Parameter Name="original_animeID" Type="Int32" />
                <asp:Parameter Name="animeID" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>

Thanks for your help!

谢谢你的帮助!

回答by Anthony Truskinger

It seems to be failing looking for another AnimeImage.

寻找另一个 AnimeImage 似乎失败了。

I'd suggest matching the casing (capitalization, don't use under_case) and order of the arguments the error page is asking for.

我建议匹配大小写(大写,不要使用 under_case)和错误页面要求的参数顺序。

Something like

就像是

[DataObjectMethod(DataObjectMethodType.Update)]
public static void UpdateAnimeList(string name, string **animeImage**, string synopsis, 
    string type, short episodes, string genres, decimal rating, int original_animeID,
int animeID) {
    ...
}