Calling a procedure in C# with parameters
Posted by: Derek Lansing
Date: September 27, 2005 11:26AM

I am trying to call a stored procedure in version 5 beta from a C# program. My stored procedure is:

CREATE PROCEDURE `oib2b_test`.`Trace_LogRequest`(_Username varchar(255),
_AccessDateTime datetime,
_MethodCalled varchar(255),
_IPAddress varchar(50),
_XMLIn varchar(255))
BEGIN
insert into trace values(_Username, _AccessDateTime, _MethodCalled, _IPAddress, _XMLIn);
END




I am calling it with this code:

public override bool AddTraceToLog(string username, DateTime accessDateTime, string methodCalled, string ipAddress, string xmlIn)
{
MySqlCommand MySqlCmd = new MySqlCommand();

AddParamToMySqlCmd(MySqlCmd, "_ReturnValue", MySqlDbType.Int16, 0, ParameterDirection.ReturnValue, null);
AddParamToMySqlCmd(MySqlCmd, "_Username", MySqlDbType.VarChar, 255, ParameterDirection.Input, username);
AddParamToMySqlCmd(MySqlCmd, "_AccessDateTime", MySqlDbType.Datetime, 0, ParameterDirection.Input, accessDateTime);
AddParamToMySqlCmd(MySqlCmd, "_MethodCalled", MySqlDbType.VarChar, 255, ParameterDirection.Input, methodCalled);
AddParamToMySqlCmd(MySqlCmd, "_IPAddress", MySqlDbType.VarChar, 50, ParameterDirection.Input, ipAddress);
AddParamToMySqlCmd(MySqlCmd, "_XMLIn", MySqlDbType.VarChar, 0, ParameterDirection.Input, xmlIn);

SetCommandType(MySqlCmd,CommandType.StoredProcedure, SP_TRACE_LOGREQUEST);
ExecuteScalarCmd(MySqlCmd);
int returnValue = (int)MySqlCmd.Parameters["_ReturnValue"].Value;
return (returnValue == 0 ? true : false);
}



I am getting an error of:

Server was unable to process request. --> #42000Incorrect number of arguments for PROCEDURE oib2b_test.Trace_LogRequest; expected 5, got 1



I don't know what I am doing wrong. If anyone could help me, it would be greatly appreciated. I know that the user I am using has the permissions to access the db because I've already had that error.

Thank you.

Options: ReplyQuote


Subject
Views
Written By
Posted
Calling a procedure in C# with parameters
1070
September 27, 2005 11:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.