4 messages in com.mysql.lists.dotnetStored Procedure in ASP.NET with MySQ...
FromSent OnAttachments
Jesse04 Jul 2006 05:26 
DG...@ NEFACOMP04 Jul 2006 05:54 
Jesse04 Jul 2006 05:54 
Jesse04 Jul 2006 06:02 
Subject:Stored Procedure in ASP.NET with MySQLConnector
From:Jesse (jl@msdlg.com)
Date:07/04/2006 05:26:10 AM
List:com.mysql.lists.dotnet

When I try to run my stored procedure in ASP.NET I get the error, "MySql.Data.MySqlClient.MySqlException: Parameter '?' must be defined". I'm not sure what I'm doing wrong here. Here's the ASP.NET code I'm using to execute the procedure:

<%@ Import Namespace="System.Data"%> <Script Runat="Server"> function GetNextInv(nChapterID As Integer) As String Dim Cmd As MySQLCommand, Conn AS MySQLConnection Dim ParamInvNo As MySQLParameter

Conn = OpenConn

Cmd = New MySQLCommand("sp_GetNextInv", Conn) Cmd.CommandType = CommandType.StoredProcedure Cmd.Parameters.Add("ChapterID",nChapterID) ParamInvNo = New MySQLParameter("InvNo",MySQLDBType.VarChar,7) ParamInvNo.Direction = ParameterDirection.Output Cmd.Parameters.Add(ParamInvNo)

Cmd.ExecuteNonQuery()

GetNextInv = CStr(Cmd.Parameters("@InvNo").Value) Cmd=Nothing Conn.Close Conn=Nothing end function </script>

Here's the stored procedure itself:

CREATE PROCEDURE `sp_GetNextInv`( IN nChapterID Int, OUT cInvNo VarChar(7)) BEGIN Declare cPrefix VarChar(1); Declare cNextInv VarChar(7); Set cInvNo = '';

IF nChapterID > 0 THEN SELECT TempInvNo INTO cInvNo FROM Chapters WHERE ID=nChapterID; END IF;

IF (cInvNo = '') or (cInvNo IS NULL) THEN SELECT NextInvoiceNo INTO cInvNo FROM Config; SET cNextInv = Right('0000000' + CONVERT(CONVERT(cInvNo, UNSIGNED) + 1, CHAR), 7); UPDATE Config SET NextInvoiceNo=cNextInv; IF nChapterID = -1 THEN Set cInvNo = CONCAT('L',Right(CONCAT('000000',cInvNo),6)); END IF; IF nChapterID = -2 THEN Set cInvNo = CONCAT('C',Right(CONCAT('000000',cInvNo),6)); END IF; IF nChapterID > 0 THEN SELECT CT.InvPrefix INTO cPrefix FROM ChapterType CT, Chapters C WHERE C.ID=nChapterID AND CT.ChapterType=C.ChapterType; Set cInvNo = CONCAT(cPrefix,Right(CONCAT('000000',cInvNo),6)); UPDATE Chapters SET TempInvNo=cInvNo WHERE ID=nChapterID; END IF; END IF; END

Anyone know what's going on here?