0

我有一个像这样的对象数据源:

 <asp:ObjectDataSource ID="VacancyObjectDataSource" runat="server" SelectMethod="GetVacancy" 
        TypeName="HRcomgeWebApp.DataLayer.DataSets.MainDataSetTableAdapters.ViewVacancyTableAdapter" OnSelecting="VacancyObjectDataSource_Selecting" OnSelected="VacancyObjectDataSource_Selected">
        <SelectParameters> 
            <asp:Parameter Name="VacancyID" Type="Int32" />
            <asp:Parameter Name="Language" Type="Int32" />
            <asp:Parameter Name="Status" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>

和这样的表单视图:

<asp:FormView ID="VacancyFormView" runat="server" DataKeyNames="VacancyID" DataSourceID="VacancyObjectDataSource"
        CellPadding="0" CellSpacing="0" GridLines="None" BorderStyle="NotSet" width="100%">

..

我的xsd代码是这样的:

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
        [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]


[global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, true)]
    public virtual MainDataSet.VacancyDataTable GetVacancy(global::System.Nullable<int> VacancyID) {
        this.Adapter.SelectCommand = this.CommandCollection[0];
        if ((VacancyID.HasValue == true)) {
            this.Adapter.SelectCommand.Parameters[1].Value = ((int)(VacancyID.Value));
        }
        else {
            this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value;
        }
        MainDataSet.VacancyDataTable dataTable = new MainDataSet.VacancyDataTable();
        this.Adapter.Fill(dataTable);
        return dataTable;
    }
and this one

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]


    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
        private void InitCommandCollection() {
            this._commandCollection = new global::System.Data.SqlClient.SqlCommand[1];
            this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand();
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "dbo.hr_GetVacancy";
            this._commandCollection[0].CommandType = global::System.Data.CommandType.StoredProcedure;
            this._commandCollection[0].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[0].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@VacancyID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[0].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Language", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[0].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Status", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[0].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@ShowOld", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
        }

但我收到了这个错误

ObjectDataSource 'VacancyObjectDataSource' could not find a non-generic method 'GetVacancy' that has parameters: VacancyID, Language, Status.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: ObjectDataSource 'VacancyObjectDataSource' could not find a non-generic method 'GetVacancy' that has parameters: VacancyID, Language, Status.
4

0 回答 0