Page 1 of 1

Named Parameters Prefix problem

Posted: Mon 14 Jul 2014 17:51
by lkrueger
Hi! I recently switched from the mySql net/connector to dotConnect and am having an issue with Stored Procedures and named Parameters. I've read the documentation, however what it says does not seem to be what it does, I'm guessing I'm missing a finer point.

I would like to use the '@' prefix for named parameters so I don't have to change a lot of code, however I can only get them to work using the ':' prefix or no prefix at all

Here is my stored procedure

Code: Select all

CREATE PROCEDURE pGetUserSalt(uname varchar(16), OUT salt varchar(32))
Begin
	Set salt = (Select uSalt From tblUsers Where uUsername=uname);
End
and here is my part of the code to retrieve the salt

Code: Select all

MySqlCommand cmd = new MySqlCommand()
{
      CommandText = "pGetUserSalt",
      Connection = conn,
      CommandType = CommandType.StoredProcedure
};

cmd.Parameters.AddWithValue("@uname", _username);

MySqlParameter pSalt = new MySqlParameter()
{
     ParameterName = "@salt",
     Direction = ParameterDirection.Output,
     MySqlType = MySqlType.VarChar,
     Size = 32
};

cmd.Parameters.Add(pSalt);
Any idea why '@' doesn't work?! Any help would be appreciated. Thanks!

Re: Named Parameters Prefix problem

Posted: Wed 16 Jul 2014 15:32
by Pinturiccio
This is designed behaviour. If you use CommandType.StoredProcedure, you can use any parameter names, however, the prefix '@' must not be used. We will add the information about this prefix in our documentation.

Re: Named Parameters Prefix problem

Posted: Wed 16 Jul 2014 16:42
by lkrueger
Thanks for the info