Click here to Skip to main content
15,913,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI
I am using the following code to call the stored procedure and I am getting the errror the The function or routine not found in the databasebut it is in the database and it works well when i restart my solution pl check my Stored procedures and tell me where i went wrong
C#
public DataTable getPermanentAddress(string strAssID)
    {
        //strCon.Open();
        DataTable dtAddress = new DataTable();
        strCon = new MySqlConnection(strConnection);
        strCon.Open();
        MySqlCommand cmdPermanentAddress = strCon.CreateCommand();//new MySqlCommand("sp_getPermanentAddress", strCon);
        try
        {
            cmdPermanentAddress.CommandText = "sp_getPermanentAddress";
            MySqlDataAdapter daPermanentAddress = new MySqlDataAdapter(cmdPermanentAddress);
            daPermanentAddress.SelectCommand.Parameters.Add("@AssociateId",MySqlDbType.Int32).Value = strAssID.ToString().Trim();
            daPermanentAddress.SelectCommand.CommandType = CommandType.StoredProcedure;
            daPermanentAddress.Fill(dtAddress);
            return dtAddress;
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        finally
        {
            if (strCon.State == ConnectionState.Open)
            {
                cmdPermanentAddress.Dispose();
                strCon.Close();
                strCon.Dispose();
            }
        
        }
    }

My routine:
C#
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_getPermanentAddress`(In AssociateId integer)
BEGIN
select permanent_add from associate_details where associate_id = AssociateId;
END

Please tell where is the issue
Posted
Updated 27-Jan-12 2:31am
v4
Comments
[no name] 27-Jan-12 8:27am    
Have you verified the connection string is using the correct database?
Shashwath7 27-Jan-12 8:31am    
yes it is correct only it works well but some times it fails for example if i login to that page it works again i get logged out and try to login it doesnt and vice versa
[no name] 27-Jan-12 8:34am    
Then you have issues with the login and security to identify, not with this code.
ZurdoDev 9-Feb-12 15:49pm    
I see strConnection but where is that getting set?

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