EXEC command

To execute a stored procedure in MicroDal, You have to call it as a valid SQL string:

ses.Execute("EXEC MyProc @param1, @param2", "Hello", 123);


Using this syntax, allows You to chose the naming of the parameters yourself. Be aware that the order of parameters is signinficant

Outputparameters

Some procedures use Output or ReturnValue parameters. To use these types of parameters, You have to ad them as DbParameter types. With SqlClient it can be done like this:

var id = new SqlParameter("@ID", -1) { Direction = ParameterDirection.InputOutput };
var err = new SqlParameter("@ErrorCode", -1) { Direction = ParameterDirection.ReturnValue };

ses.Execute("SessionLog_Insert /*@AppName, @UserId*/", "Test", "60288729", id, err);

It is then possible to read the values through the parameters Value property.

Last edited Jul 4, 2014 at 7:50 AM by TheIMan, version 5