Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Unable to call stored procedure with OUT argument (1 reply)

$
0
0
I am converting a Ms SQL Server application to work with MySQL. I am not able to call stored procedures with OUT arguments. I have looked through the documentation but I cannot figure out how to do it from my .NET code. This is what I am doing:

Stored Procedure:

CREATE PROCEDURE AsientoSencillo
(
IN _deudora nchar(10),
IN _acreedora nchar(10),
IN _cantidad decimal(9,3),
IN _comentario nchar(255),
IN _fecha datetime,
OUT _nuevo_asiento int
)

...

C# Code:

using(MySqlConnection conn = DBCon.Connect()) {
conn.Open();
MySqlCommand cmd = new MySqlCommand("CALL AsientoSencillo(@deudora, @acreedora, @cantidad, @comentario, @fecha, @nuevo);", conn);
cmd.Parameters.AddWithValue("@deudora", deudora);
cmd.Parameters.AddWithValue("@acreedora", acreedora);
cmd.Parameters.AddWithValue("@cantidad", cantidad);
cmd.Parameters.AddWithValue("@comentario", comentario);
cmd.Parameters.AddWithValue("@fecha", fecha);
MySqlParameter p = cmd.CreateParameter();
p.ParameterName = "@nuevo";
p.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p);
cmd.ExecuteNonQuery();
}

And the error is:

OUT or INOUT argument 6 for routine conta2.AsientoSencillo is not a variable or NEW pseudo-variable in BEFORE trigger

This type of code would have worked well with Ms SQL Server. I cannot see what is wrong with it. Please, could you help me?

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>