C
C#2y ago
uselessxp

❔ Dapper - Call stored procedure error

I finished to write my first POST Api, but I get an error when I execute it and it call a stored procedure. -$exception {"OUT or INOUT argument 1 for routine mydb.storedprocedure is not a variable or NEW pseudo-variable in BEFORE trigger"} MySqlConnector.MySqlException ErrorCode StoredProcedureNotVariableArgument MySqlConnector.MySqlErrorCode I checked all parameters, count and names, and they are ok, what am I forgetting?
2 Replies
uselessxp
uselessxpOP2y ago
update: I gained the access to the DB and I noticed that the procedure I'm calling have the first parameter as INOUT, then I setted my parameter to INOUT
var p = new DynamicParameters();
p.Add("idUser", user.idUser, direction: ParameterDirection.InputOutput);
var p = new DynamicParameters();
p.Add("idUser", user.idUser, direction: ParameterDirection.InputOutput);
but this was not enough to solve, it continue to say that the 1st parameter have some error 🤔 update: I noticed that I continuosly still get error because standing to the debugger, a dynamic parameter direction can be only input if I use it in a text command (I think it refers to the fact I use text to call the procedure with SQL) don't understand this but I used a "workaround", I setted the idUser adding a SQL row in the command
_dbConnection.Execute($@"
SET @idUser = {user.idUser};
CALL mydb.storedprocedure(@. . . . .)
_dbConnection.Execute($@"
SET @idUser = {user.idUser};
CALL mydb.storedprocedure(@. . . . .)
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server