I've inherited a rather old ASP.NET application that runs on our company intranet. The server it is on is extremely old and I am trying to get it working on a slightly newer server but I am having an issue with some MySQL Stored Procedures.
The error I am catching is "FUNCTION mann_production.spGetDraftID does not exist"
Here is the way I am creating the command object and calling ExecuteScalar()
Using connection As New MySqlConnection(ConfigurationManager.ConnectionStrings("MYSQL5_Products").ConnectionString)
Using command As New MySqlCommand("spGetDraftID", connection)
command.CommandType = Data.CommandType.StoredProcedure
command.Parameters.Add(New MySqlParameter("?parModuleID", ModuleID))
command.Parameters.Add(New MySqlParameter("?retNewModuleID", "0"))
command.Parameters("?retNewModuleID").Direction = Data.ParameterDirection.ReturnValue
connection.Open()
Try
command.ExecuteScalar()
Catch e As Exception
Return Nothing
End Try
Return command.Parameters("?retNewModuleID").Value
End Using
End Using
I have the ConnectionString defined in Web.config.
<connectionStrings>
<add name="MySQL5_Products" connectionString="Server=localhost; User ID=mannsql; Pwd=XXXXXX; pooling=true; Max Pool Size=300; Persist Security Info=true; Database=mann_production" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
The Stored Procedure in my MySQL database definitely exists. This is it.
DELIMITER $$
USE `mann_production`$$
DROP PROCEDURE IF EXISTS `spGetDraftID`$$
CREATE DEFINER=`mannsql`@`` PROCEDURE `spGetDraftID`(
IN parModuleID INT(11),
OUT retNewModuleID INT(11))
COMMENT 'Either makes a draft of the given Module ID or returns the ID of'
BEGIN
/* Find draft if exists */
SET retNewModuleID = (SELECT Module.ModuleID
FROM Module INNER JOIN Module AS Module_1 ON Module.ModuleName = Module_1.ModuleName
WHERE ((Module.Rev = 'Draft') AND (Module_1.ModuleID = parModuleID))
LIMIT 1);
IF (IFNULL(retNewModuleID, 0) = 0) THEN
/*Create a new Module Draft*/
INSERT INTO Module ( Module.ModuleName, Module.Rev, Module.MinorRevision, Module.Current, Module.Description, Module.Notes) SELECT Module.ModuleName, 'Draft' AS Rev, 1 AS MinorRevision, 0 AS CURRENT, Module.Description, Module.Notes FROM(Module) WHERE (((Module.ModuleID)=parModuleID)) LIMIT 1;
/* Get the ID*/
SET retNewModuleID = (SELECT LAST_INSERT_ID());
/*Copy Operations*/
INSERT INTO ModuleOperations ( ModuleOperations.OP, ModuleOperations.Description, ModuleOperations.ModuleID ) SELECT ModuleOperations.OP, ModuleOperations.Description, retNewModuleID AS Expr1 FROM(ModuleOperations) WHERE (((ModuleOperations.ModuleID)= parModuleID));
/* Copy Parts */
INSERT INTO ModuleBOM ( ModuleBOM.OP, ModuleBOM.Seq, ModuleBOM.ItemID, ModuleBOM.Qty, ModuleBOM.Um, ModuleBOM.Ref, ModuleBOM.Notes, ModuleBOM.ModuleID ) SELECT ModuleBOM.OP, ModuleBOM.Seq, ModuleBOM.ItemID, ModuleBOM.Qty, ModuleBOM.Um, ModuleBOM.Ref, ModuleBOM.Notes, retNewModuleID AS Expr1 FROM(ModuleBOM) WHERE (((ModuleBOM.ModuleID)=parModuleID));
/* Add New Revision Record */
INSERT INTO ModuleReleaseNotes (ModuleReleaseNotes.OldModuleID, ModuleReleaseNotes.NewModuleID, ModuleReleaseNotes.Revision) VALUES (parModuleID, retNewModuleID, 'Draft');
END IF;
END$$
DELIMITER ;
Any ideas would be greatly appreciated.
Cheers.