0

I am having a problem returning an output parameter from a Mysql stored procedure into a ASP.NET Variable. I just want the ligne code to use in ASP to get that Parameter ! Thank you

1
  • It would be awesome if you could share a minimal reproducible example of your progress so far. Commented Jul 28, 2019 at 13:11

1 Answer 1

1

let's suppose that there is a parameter named 'MyOutParam' which is an output type of parameter for your MySQL stored procedure. In that case what you will have to do is:

// here goes the logic of instantiating the command for a stored procedure

// cmd is the reference variable containing instance of SQLCommand
cmd.Parameters.Add(new MySqlParameter(“MyOutParam”, MySqlDbType.VarChar));
cmd.Parameters[“MyOutParam”].Direction = ParameterDirection.Output;         // this is how we declare the parameter to be of 'output' type.

cmd.ExecuteNonQuery();

// this is how we can get the value in the output parameter after stored proc has executed
var outParamValue = cmd.Parameters[“MyOutParam”].Value;
Sign up to request clarification or add additional context in comments.

3 Comments

I suspect that code won't compile as is due to .
Thank you sir , i'll try it :)
Oh great it's work :) thank you very much for your help and support!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.