Bug #38221 AddUsersToRoles fails
Submitted: 18 Jul 2008 9:09 Modified: 29 Aug 2008 9:52
Reporter: Marouane BOUZOUBAA Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.2.2 OS:Any
Assigned to: CPU Architecture:Any
Tags: Membership Provider, MySql Connector .NET, Role Provider

[18 Jul 2008 9:09] Marouane BOUZOUBAA
Description:
the method AddUsersToRoles should be able to associate users to roles. but it fails with the following exception:

[MySql.Data.MySqlClient.MySqlException] = {"Column count doesn't match value count at row 1"}

How to repeat:
execute :

Roles.AddUserToRole("user", "role");

Suggested fix:
Add null to the 3rd column (auto-increment key)

replace 

MySqlCommand cmd = new MySqlCommand(
                            "INSERT INTO adm_aspnet_usersinroles VALUES(@userId, @roleId, null)", connection);

with

MySqlCommand cmd = new MySqlCommand(
                            "INSERT INTO adm_aspnet_usersinroles VALUES(@userId, @roleId, null)", connection);
[18 Jul 2008 9:11] Marouane BOUZOUBAA
The original statement lacks the null value

MySqlCommand cmd = new MySqlCommand(
                            "INSERT INTO adm_aspnet_usersinroles VALUES(@userId, @roleId)", connection);
[18 Jul 2008 11:06] Tonci Grgin
Hi Marouane and thanks for your report.

I must admit I'm completely puzzled by http://msdn.microsoft.com/en-us/library/system.web.security.roleprovider.adduserstoroles.a...... 

C# structure is indeed 2 field:
public abstract void AddUsersToRoles(
    string[] usernames,
    string[] roleNames
)
while table itself asks for 3: Username, Rolename, ApplicationName

I will look into my books and consult colleagues now. In the meantime, please reconsider our bug reporting guidelines as I fail to see how this problem, with such an easy, and understandable, workaround could be S1:
  S1 (Critical): Represents a complete loss of service, a significant functionality is missing, a system that hangs indefinitely; and there is no available workaround.

Please lower the severity to, at least, S3.
[18 Jul 2008 11:13] Marouane BOUZOUBAA
severity revision
[18 Jul 2008 12:02] Tonci Grgin
Hi Marouane and thanks for lowering severity (I'm not allowed to change your input in any way). Let's see what my colleague(s) have to say.
[18 Jul 2008 17:03] Reggie Burnett
Unable to reproduce this.  The my_aspnet_UsersInRoles table only uses two columns.  The application connection is handled with the user id so all that is needed is a user id and a role id.  It sounds like your schema is not updated. What version membership schema do you have?
[29 Aug 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".