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

Asked By abinav shankar on 18-Jan-12 07:08 AM
Hi
 
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
int leaveReqId = 0;
    Con = new MySqlConnection(conn);
    Con.Open();
    MySqlCommand cmdLeaveReqId = new MySqlCommand("sp_getLeaveReqId",Con);
    cmdLeaveReqId.Parameters.Add("@AssociateId", MySqlDbType.Int32).Value = Convert.ToInt32(strAssId.Trim());
    cmdLeaveReqId.Parameters.Add("@leaveType", MySqlDbType.String).Value = strLeaveType.Trim();
    cmdLeaveReqId.Parameters.Add("@leaveStatus", MySqlDbType.String).Value = strLeaveStatus.Trim();
    cmdLeaveReqId.CommandType = CommandType.StoredProcedure;
    MySqlDataReader drLeaveReqId = cmdLeaveReqId.ExecuteReader();
    drLeaveReqId.Read();
    leaveReqId = Convert.ToInt32(drLeaveReqId["leave_req_id"].ToString().Trim());
    Con.Close();
    return leaveReqId;

Routine:
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_getLeaveReqId`(In AssociateId integer,In leaveType varchar(45),in leaveStatus varchar(45))
BEGIN
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;
END

pl tell me where i went wrong
Jitendra Faye replied to abinav shankar on 18-Jan-12 07:10 AM
While connecting with database first check that -

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

Check your connection string.


let me know.