我继承了一个在我们公司内部网上运行的相当旧的asp.net应用程序。它所在的服务器非常旧,我正试图让它在稍新的服务器上工作,但我遇到了一些mysql存储过程的问题。
我发现的错误是“function mann\u production.spgetdraftid不存在”
下面是我创建command对象并调用 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
我在web.config中定义了connectionstring。
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 ;
任何想法都将不胜感激。
干杯。
暂无答案!
目前还没有任何答案,快来回答吧!