Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a query and i am trying to bind class inside a dropdown but it showing the following error...

"Procedure or function 'BindSectionByTeacher' expects parameter '@SchoolId', which was not supplied."

I Understand the error but i think i have supplied the SchoolId ....Below is my query....

SQL
ALTER PROCEDURE [dbo].[BindClassByTeacher]
@TeacherId int,
@SchoolId int
AS
BEGIN
    select T.AllowtedClass,T.ClassId from TeacherAllowtedClass T
    inner join SchoolMaster S
    on S.School_ID=T.School_ID
    where  T.School_ID=@SchoolId and T.Teacher_ID=@TeacherId
    Order by T.ClassId
END


and my backend coding is...

DbConnection bind = new DbConnection();
            bind.BindDropdownlist_para(ddlclass, "[BindClassByTeacher]", "AllowtedClass", "ClassId", "@SchoolId", Session["School"].ToString(),
                "@TeacherId", Session["teacherid"].ToString());


Allowted Class ClassId
   11th   	2
   Nursery	4
   10th	        8



Please try to help me...thanx....
Posted
Updated 5-Jun-14 1:13am
v4
Comments
Saral S Stalin 6-Jun-14 4:35am    
Please post code for BindDropdownlist_para

Hi Ashraf,

In your stored procedure input parameters are of type integer. And in code behind you are using string values.

I think that is why you are getting error. Check that once.
 
Share this answer
 
Comments
Md.Ashraf Ali 5-Jun-14 7:23am    
Hi Ajith,

this is my session value....
int SchoolId = Convert.ToInt16(dr["School_ID"]);
Session["SchoolId"] = SchoolId;
This is in interger i dunno what to do....could u write something for me...
Convert the string to int in the below code

Use Convert.ToInt32(Session["School"]) instead of Session["School"].ToString()
 
Share this answer
 
Comments
Md.Ashraf Ali 5-Jun-14 7:26am    
Hi NAZ
this is my session value....
int SchoolId = Convert.ToInt16(dr["School_ID"]);
Session["SchoolId"] = SchoolId;
This is in interger i dunno what to do....could u write something for me...
Naz_Firdouse 5-Jun-14 8:45am    
though you are storing int vaules in the session , while getting the values from session, you need to case the values as per the required datatype...
so you need to convert the session value to int while passing it to stored procedure...
because your SP expects an integer not a string...
Naz_Firdouse 5-Jun-14 8:46am    

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