Click here to Skip to main content
16,019,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem with my search im trying to search using 2 parameters but it giving meAN ERROR says : Procedure or function 'Learner_Existance' expects parameter'@AccessionNo', which was not supplied.

Here is my Store Proc...
create procedure [dbo].[Learner_Existance]
@EmisCode varchar(9),
@AccessionNo nvarchar(250)
AS
Select  EmisCode,
        AccessionNo,
        Fname,
        Sname,
        Initials,
        Gender,
        Title ,
        BirthDate ,
        Religion,
        Address1 ,
        Address3 ,
        AddressCode,
        HomeLanguage ,
        InstructionLanguage ,
        PreferredLanguage ,
        Race,
        Citizenship,
        PreviousSchoolProvince,
        PreviousPlacementofSchool ,
        PreviousSchool,
        ProvinceResidence,
        PhysProvince ,
        Transport,
        DeceasedParent,
        LuritsNumber from Learner_Info   
where EmisCode=@EmisCode
and AccessionNo = @AccessionNo

..................................................................................
Here My Business Layer

VB
Public Function Get_Learner(ByVal Code As String, ByVal Num As String) As List(Of Learner)


        Dim objDal As New csSQLDALVB
        Dim objParList As New List(Of csParameterListType)
        Dim objList As New List(Of Learner)
        Dim dr As IDataReader


        objParList.Add(New csParameterListType("@EmisCode", SqlDbType.VarChar, Code))
        objParList.Add(New csParameterListType("@AccessionNo", SqlDbType.NVarChar, Num))

        dr = objDal.executespreturndr("Learner_Existance", objParList)

        Using dr
            While dr.Read
                Dim ll As New Learner
                populate_reader(dr, ll)
                objList.Add(ll)
            End While
        End Using
        Return objList
    End Function



..................................................................................
And My Client Side

VB
Protected Sub btnsearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnsearch.Click

        Dim objL As New Learner
        Dim objlist As New List(Of Learner)
        Dim code As String
        Dim accesion As String

        Try
            objlist = objL.Get_Learner(txtEmiscode.Text, txtAccession.Text)
            For Each ll As Learner In objlist
                If objlist.Count <> 0 Then

                    code = ll.EmisCode
                    accesion = ll.AccessionNo
                    Response.Redirect("~/Emis_LearnerView.aspx" & "?EmisCode=" & code & "?AccessionNo=" & accesion)
                Else
                    lblerror.Text = "cannot find student"
                End If
            Next

        Catch ex As Exception
            lblerror.Text = ex.Message

        End Try

    End Sub
End Class




please help me guys it almost a week now
Posted
Updated 23-Sep-11 1:16am
v2
Comments
Simon Bang Terkildsen 23-Sep-11 7:21am    
I don't see any problems, but I guess if Num is null or an empty string in Get_Learner then you might get the exception, have you ensured Num is set to a non empty string?

You should state which database you're using as some of the CP members might know of some limitations/weird behavior in the specefic databases.
zamani2 23-Sep-11 7:30am    
well i'm using sql 2008

1 solution

Check for null parameters and if so use DBNull instead. Also, check out this link:
http://dhondiyals.wordpress.com/2011/05/05/procedure-or-function-expects-parameter-which-was-not-supplied-resolved/[^]

Good luck!
 
Share this answer
 
Comments
zamani2 23-Sep-11 8:22am    
it does not help me because i'm using 3 tier and this code u telling about it a one tier.. can give me other solution please.. so tell me where did i go wrong in my code
E.F. Nijboer 23-Sep-11 10:07am    
Okay, let's assume the things mentioned are all correctly handled. The problem is probably that you need to set the size of your nvarchar parameter to -1. Have a look at the link for more on this:

http://weblogs.asp.net/jeffwids/archive/2008/08/15/nvarchar-max-parameters-need-the-size-set-to-1.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900