Using the new Connector/Net Web providers

Yesterday I blogged about the release of our latest Connector/Net product.  Version 5.1, this release includes the addition of a new namespace MySql.Web.  This namespace includes implementations of a Membership and Role provider.  These providers work together with the membership and role systems in ASP.Net 2.0 to provide a simple mechanism for web developers to add authentication and role support to their web properties.

As we were unable to include proper documentation for these new providers before release, I thought it proper to write down a few thoughts on how these work and how to use them.

1. Provide a connection string

The Connector/Net installer will register the providers in the proper sections of the machine.config file.  When registered, they reference a connection string that is non-existent.  To use the providers, you must provide a connection string that points to the database you wish to use and must be named 'LocalMySqlServer'.   You would provide this connection string in your web.config file.  Here is an example:

<connectionStrings>

<add name="LocalMySqlServer" connectionString="data source=localhost;uid=root;pooling=false" providerName="MySql.Data.MySqlClient" />

</connectionStrings>

You can also use the Web Configuration Pages in Visual Studio to select the MySQL Membership and Role providers as defaults for your application.  Once this is done, controls such as the Login control will work with MySQL.

2. Understand how the schema is handled

We wanted the providers to work with shared hosting environments where only a single database may be available.  To do this, the providers can create or update the necessary schema at runtime.  This is handled at initialization time.  The provider checks the version of the schema in the selected database.  If non-existent, then the appropriate schema is created.  If older than current, it will be updated to match what this provider is wanting.

There is a possibility of name collision since your tables and the tables for the providers exist in the same database.  This is unlikely, though, since the names given to the provider tables are somewhat unique to their purpose.

We're working on better documentation for these providers and plan to make that available with the 5.1.1 release.  Also, we plan to create some articles for our dev zone that will demonstrate how to use these providers.


Related posts

Comments

May 4. 2007 04:46 PM

I'm looking the ByteFX.Data.
but http://www.bytefx.com/dotdata.aspx is down now.

mao

May 8. 2007 09:07 PM

raithe davion

I've tried using the providers, and I've added the connection string, however when I try to test the connection it never can connect to the database. In any case, none of the tutorials I've read have been extremely clear. All of the provider and connectionString info are in my machine.config file, not my web.config file. Thats w/o changing anything. Can you write a more detailed tutorial? I have IIS 6 and MySql running on a local machine. Step by step, how do I set it up so ASP.NET's login controls and such can use MySql.

raithe davion

July 24. 2007 03:32 PM

Jorge Gomez Santillan

Hi Reggie, i read http://bugs.mysql.com/bug.php?id=24138 , i have the same connectionstring with the statement pooling=false, but the connections mantain your state SLeep in Mysql, i'm using mysql net connector 5.0.3 and mysql 5.0.27 win32. Exists any way to kill this sleep process ? Thks.

Jorge Gomez Santillan

July 24. 2007 05:20 PM

Reggie

Jorge

This really shouldn't be happening. Are you sure the connection is getting closed()?

Reggie

July 28. 2007 10:45 AM

William Pierce

Reggie,

Am having a problem with the 5.0.7 connector. I have an app that makes about 1200 web page calls a minute. Each call to the web page makes a call to a database stored procedure (S). After about 24 hours of running, connector/5.0.7 fails by throwing an "out of memory" exception.

Any ideas on how I can resolve this?

Thanks,

Bill

The stack trace I get is as follows:

System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
at System.Text.StringBuilder.Append(String value)
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.SetValue(String keyword, Object value)
at MySql.Data.MySqlClient.MySqlConnection.ChangeDatabase(String database)
at MySql.Data.MySqlClient.MySqlConnection.Open()


William Pierce

July 30. 2007 03:14 AM

Nalle Jacobsson

Bill, It's a bug in the connector:

http://bugs.mysql.com/bug.php?id=29123

Nalle Jacobsson

July 31. 2007 09:16 AM

William Pierce

Nalle,

Thanks for your response. Not sure why you think the two are related. In my case calling the same stored procedure a few million times causes the app to run out of memory.

I also verified that in my case the connection string does not grow with each subsequent invocation.

So, either I did not read this bug correctly, or else my bug is a different one in the 5.0.7 connector.

Thanks,

Bill

William Pierce

August 6. 2007 06:04 AM

Nalle Jacobsson

Bill,

In our case, the connection string got bigger and bigger, and finally we ended up with out of memory exceptions and high cpu due to excessive garbage collection. We solved the problem by reverting to 5.0.5.

Nalle Jacobsson

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

July 5. 2008 03:42 AM

Search

Tags

Don't show

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008