Bug #33347 FindByUsers ASP.Net 2.0 Membership
Submitted: 18 Dec 2007 21:07 Modified: 10 Jan 2008 17:29
Reporter: Klas Nilsson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.1.4 OS:Windows
Assigned to: CPU Architecture:Any

[18 Dec 2007 21:07] Klas Nilsson
Description:
Can't use the following ASP.NET 2.0 built-in Membership provider-method in MySQL Connector/Net 5.1.4.

Public Shared Function FindUsersByEmail(ByVal emailToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Member of: System.Web.Security.Membership

The following errormessage appears:

An exception occurred. Please check the Event Log. vid System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) vid System.Web.Administration.SecurityPage.SearchForUsers(Object sender, EventArgs e, Repeater repeater, GridView dataGrid, DropDownList dropDown, TextBox textBox) vid ASP.security_users_manageusers_aspx.SearchForUsers(Object sender, EventArgs e) vid System.Web.UI.WebControls.Button.OnClick(EventArgs e) vid System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) vid System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) vid System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) vid System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) vid System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

This is what the Event-log printed:

An exception occurred communicating with the data source.

Action: FindUsersByEmail

Exception: MySql.Data.MySqlClient.MySqlException: Parameter '?EmailSearch' has already been defined.
   vid MySql.Data.MySqlClient.MySqlParameterCollection.InternalAdd(MySqlParameter value, Int32 index)
   vid MySql.Data.MySqlClient.MySqlParameterCollection.Add(String parameterName, MySqlDbType dbType, Int32 size)
   vid MySql.Web.Security.MySQLMembershipProvider.FindUsersByEmail(String emailToMatch, Int32 pageIndex, Int32 pageSize, Int32& totalRecords)

Mer information finns i Hjälp- och supportcenter på sidan http://go.microsoft.com/fwlink/events.asp.

How to repeat:
Use the method "Membership.FindUsersByEmail()" to find users registered.
The method "Membership.FindUsersByName()" on the other hand does NOT throw any Exception. The latter also correctly supports wildcard characters.

Suggested fix:
This is what the Event-log printed:

An exception occurred communicating with the data source.

Action: FindUsersByEmail

Exception: MySql.Data.MySqlClient.MySqlException: Parameter '?EmailSearch' has already been defined.
   vid MySql.Data.MySqlClient.MySqlParameterCollection.InternalAdd(MySqlParameter value, Int32 index)
   vid MySql.Data.MySqlClient.MySqlParameterCollection.Add(String parameterName, MySqlDbType dbType, Int32 size)
   vid MySql.Web.Security.MySQLMembershipProvider.FindUsersByEmail(String emailToMatch, Int32 pageIndex, Int32 pageSize, Int32& totalRecords)

Mer information finns i Hjälp- och supportcenter på sidan http://go.microsoft.com/fwlink/events.asp.
[2 Jan 2008 21:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/40489
[2 Jan 2008 21:11] Reggie Burnett
fixed in 5.1.5
[10 Jan 2008 17:29] MC Brown
A note has been added to the 5.1.5 changelog: 

Problem with membership provider would mean that FindUserByEmail would fail with a MySqlException because it was trying to add a second parameter with the same name as the first.