Link to home
Start Free TrialLog in
Avatar of aneilg
aneilgFlag for United Kingdom of Great Britain and Northern Ireland

asked on

sql datasource select method

I get the following error, I am getting the value from the first drop down list departmentid.
Then passing this value to a stored procedure using the selectmethod of the second drop down list.

ObjectDataSource 'objdsAddColleague' could not find a non-generic method 'seladddepColleagueDetails' that has parameters: strConn, DepartmentID.
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 'objdsAddColleague' could not find a non-generic method 'seladddepColleagueDetails' that has parameters: strConn, DepartmentID.

My aspx page.
 
    <table id="tblDepartmentSelection" width="100%" border="0" style="border-bottom-width:1px; border-bottom-color:Black; border-bottom-style:solid" cellpadding="0" cellspacing="0" class="">
        <tr>
            <td align="center" style="height: 65px">
                <asp:DropDownList ID="ddlDepartment" runat="server" CssClass="" DataSourceID="objDepartmentDetails" Datatextfield="DepartmentName" DataValueField="DepartmentID" AutoPostBack="true">
                </asp:DropDownList>
                <asp:ObjectDataSource ID="objDepartmentDetails" runat="server" SelectMethod="GenericQuery" TypeName="WAB_DataAccessWS.WAB_DataAccessWS">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="hdnMainConnStr" Name="strConn" PropertyName="Value" Type="String"/>
                        <asp:Parameter defaultvalue="exec p_DepartmentDetails" name="strQuery" type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
        </tr>
    </table>
 
 
                <asp:DropDownList ID="ddlAddColleague" runat="server" CssClass="" DataSourceID="objdsAddColleague" DataValueField="ColleagueName" Datatextfield="ColleagueName" AutoPostBack="true">
                </asp:DropDownList>
                <asp:ObjectDataSource ID="objdsAddColleague" runat="server" SelectMethod="seladddepColleagueDetails" TypeName="WAB_DataAccessWS.WAB_DataAccessWS">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="hdnMainConnStr" Name="strConn" PropertyName="Value" Type="String"/>
                        <asp:ControlParameter ControlID="ddlDepartment" Name="DepartmentID" PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
 
 
My web service
    'Select add colleague
    <WebMethod()> _
    Public Function seladdColleagueDetails(ByVal strConn As String, ByVal DepartmentID As Integer) As Integer
        Return WAB_DataAccess.seladddepColleagueDetails(strConn, DepartmentID)
    End Function
 
My cls
 
    'Select method from webservice add colleaguedepartment
    Public Shared Function seladddepColleagueDetails(ByVal strConn As String, ByVal intDepartmentID As Integer) As Integer
        Using conn As New sqlconnection(strConn)
 
            Using cmd As New SqlCommand("p_AddColleague", conn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("DepartmentID", intDepartmentID)
                Try
                    conn.Open()
                    Return cmd.ExecuteNonQuery()
                Catch ex As Exception
                End Try
            End Using
 
        End Using
 
    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sunithnair
sunithnair

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aneilg

ASKER

I think i mite have tried that i'll have a look in the morning.

Thanks for your help.

Avatar of aneilg

ASKER

Thanks for that i was calling seladddepColleagueDetails instead of seladdColleagueDetails