C# .NET - Cannot find the procedure or function sp_getLeaveReqId

Asked By abinav shankar on 18-Jan-12 06:38 AM


I have created a routine and it gets executed and it is there in the list of routines in my database but when i rum my application i am getting the exception function or procedure sp_getLeaveReqId cannot be found in the data base

clsApproveOrRejectBAL objApproveOrReject = new clsApproveOrRejectBAL();
      LinkButton lnkApprove = (LinkButton)sender;
      GridViewRow gvRowApprove = (GridViewRow)lnkApprove.NamingContainer;
      LinkButton lnkAssid = (LinkButton)gvRowApprove.FindControl("lnkAssId");
      Label lblleaveType = (Label)gvRowApprove.FindControl("lblLeaveType");
      int leaveId = objApproveOrReject.getLeaveReqId(lnkAssid.Text.Trim(), "pending", lblleaveType.Text);
      objApproveOrReject.ApproveLeave(Session["userId"].ToString(), Session["userId"].ToString(), lnkAssid.Text.Trim(), 1);


CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_getLeaveReqId`(In AssociateId integer,In leaveType varchar(45),in leaveStatus varchar(45))
select leave_req_id from leave_request where leave_type_id = (select leave_type_id 
from leave_type where leave_type=leaveType) 
and leave_status_id=(select leave_status_id from leave_status where leave_status=leaveStatus) 
and associate_id=AssociateId;

pl tell me where i went wrong
D Company replied to abinav shankar on 18-Jan-12 06:49 AM
Hello Abinav,

there are certain restriction on routines, when you call it from outside, go through the below block will give you cleare idea , how to invoke it. or what u have done wroung

must read


Hope this will help u!!!
Jitendra Faye replied to abinav shankar on 18-Jan-12 06:53 AM
While connecting with database forst check that -

Are you connecting with same database , where you have created procedure.

Check your connection string.

let me know.