[Mono-aspnet-list] Send and recieve database info using stored procedures and MySQL.

ajwtech ajwtech at gmail.com
Wed Mar 23 22:53:52 EDT 2011


Ok, So I have some C# in an ASP.net page that sends parameters to a MySQL
Stored Procedure. I get the error that you see below. I have included the
Error, the C# and the stored procedure. I think the problem has something to
do with this line:
"AddParamToSQLCmd(sqlCmd, "@ReturnValue", MySqlDbType.Int32, 0,
ParameterDirection.ReturnValue, null);"

Any Ideas?



Server Error in '/' Application

Incorrect number of arguments for PROCEDURE
timetracker_dbo.aspnet_starterkits_CreateNewProject; expected 7, got 6

Description: HTTP 500. Error processing request.

Stack Trace:

MySql.Data.MySqlClient.MySqlException: Incorrect number of arguments for
PROCEDURE timetracker_dbo.aspnet_starterkits_CreateNewProject; expected 7,
got 6
  at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x00000] in :0 
  at MySql.Data.MySqlClient.NativeDriver.GetResult (System.Int32&
affectedRow, System.Int32& insertedId) [0x00000] in :0 
Version information: Mono Runtime Version: 2.8.2 (tarball); ASP.NET Version:
2.0.50727.1433




    public override int CreateNewProject(Project newProject) {

      if (newProject == null)

        throw (new ArgumentNullException("newProject"));





      MySqlCommand sqlCmd = new MySqlCommand();



      AddParamToSQLCmd(sqlCmd, "@ReturnValue", MySqlDbType.Int32, 0,
ParameterDirection.ReturnValue, null);

      AddParamToSQLCmd(sqlCmd, "@ProjectCreatorUserName",
MySqlDbType.VarChar, 255, ParameterDirection.Input,
newProject.CreatorUserName);

      AddParamToSQLCmd(sqlCmd, "@ProjectCompletionDate",
MySqlDbType.DateTime, 0, ParameterDirection.Input,
newProject.CompletionDate);

      AddParamToSQLCmd(sqlCmd, "@ProjectDescription", MySqlDbType.VarChar,
1000, ParameterDirection.Input, newProject.Description);

      AddParamToSQLCmd(sqlCmd, "@ProjectEstimateDuration",
MySqlDbType.Decimal, 0, ParameterDirection.Input,
newProject.EstimateDuration);

      AddParamToSQLCmd(sqlCmd, "@ProjectManagerUserName",
MySqlDbType.VarChar, 255, ParameterDirection.Input,
newProject.ManagerUserName);

      AddParamToSQLCmd(sqlCmd, "@ProjectName", MySqlDbType.VarChar, 255,
ParameterDirection.Input, newProject.Name);



      SetCommandType(sqlCmd, CommandType.StoredProcedure,
SP_PROJECT_CREATE);

      ExecuteScalarCmd(sqlCmd);



      return ((int)sqlCmd.Parameters["@ReturnValue"].Value);

    }



--
--------------------------------------------------------------------------------
-- Routine DDL
--
--------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`Time`@`192.168.30.1` PROCEDURE
`aspnet_starterkits_CreateNewProject`(
v_ProjectCreatorUserName  NATIONAL VARCHAR(256),
v_ProjectCompletionDate		DATETIME,
v_ProjectDescription 	  NATIONAL VARCHAR(1000),
v_ProjectEstimateDuration DECIMAL,
v_ProjectManagerUserName  NATIONAL VARCHAR(256),
v_ProjectName		  NATIONAL VARCHAR(256), 
INOUT SWP_Ret_Value INT)
SWL_return:
BEGIN
   DECLARE v_ProjectCreatorId CHAR(36); 
   DECLARE v_ProjectManagerId CHAR(36);
   select   Id INTO v_ProjectCreatorId FROM aspnet_users WHERE name =
v_ProjectCreatorUserName;
   select   Id INTO v_ProjectManagerId FROM aspnet_users WHERE name =
v_ProjectManagerUserName;

   IF NOT EXISTS(SELECT ProjectId  FROM aspnet_starterkits_Projects WHERE
LOWER(ProjectName) = LOWER(v_ProjectName)) then

  INSERT aspnet_starterkits_Projects(ProjectCreatorId,
ProjectCompletionDate,
ProjectDescription,
ProjectEstimateDuration,
ProjectManagerId,
ProjectName)
VALUES(v_ProjectCreatorId,
v_ProjectCompletionDate,
v_ProjectDescription,
v_ProjectEstimateDuration,
v_ProjectManagerId,
v_ProjectName);

      SET SWP_Ret_Value = LAST_INSERT_ID();
      LEAVE SWL_return;
   ELSE
      SET SWP_Ret_Value = 1;
      LEAVE SWL_return;
   end if;
END


--
View this message in context: http://mono.1490590.n4.nabble.com/Send-and-recieve-database-info-using-stored-procedures-and-MySQL-tp3401456p3401456.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.


More information about the Mono-aspnet-list mailing list