Named Parameters Prefix problem

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
lkrueger
Posts: 6
Joined: Mon 14 Jul 2014 17:40

Named Parameters Prefix problem

Post by lkrueger » Mon 14 Jul 2014 17:51

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!

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Named Parameters Prefix problem

Post by Pinturiccio » Wed 16 Jul 2014 15:32

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.

lkrueger
Posts: 6
Joined: Mon 14 Jul 2014 17:40

Re: Named Parameters Prefix problem

Post by lkrueger » Wed 16 Jul 2014 16:42

Thanks for the info

Post Reply