Connector/Net Tutorials
1865
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
conn.Close();
Console.WriteLine("Done.");
}
}
In this section, you have seen how to call a stored procedure from Connector/Net. For the moment, this
concludes our introductory tutorial on programming with Connector/Net.
20.2.4.2. Tutorial: MySQL Connector/Net ASP.NET Membership and Role Provider
Many web sites feature the facility for the user to create a user account. They can then log into the
web site and enjoy a personalized experience. This requires that the developer creates database
tables to store user information, along with code to gather and process this data. This represents a
burden on the developer, and there is the possibility for security issues to creep into the developed
code. However, ASP.NET 2.0 introduced the Membership system. This system is designed around
the concept of Membership, Profile and Role Providers, which together provide all of the functionality
to implement a user system, that previously would have to have been created by the developer from
scratch.
Currently, MySQL Connector/Net provides Membership, Role, Profile and Session State Providers.
This tutorial shows you how to set up your ASP.NET web application to use the MySQL Connector/Net
Membership and Role Providers. It assumes that you have MySQL Server installed, along with MySQL
Connector/Net and Microsoft Visual Studio. This tutorial was tested with MySQL Connector/Net 6.0.4
and Microsoft Visual Studio 2008 Professional Edition. It is recommended you use 6.0.4 or above for
this tutorial.
1. Create a new database in the MySQL Server using the MySQL Command-Line Client program
(
mysql
), or other suitable tool. It does not matter what name is used for the database, but record it.
You specify it in the connection string constructed later in this tutorial. This database contains the
tables, automatically created for you later, used to store data about users and roles.
2. Create a new ASP.NET Web Site in Visual Studio. If you are not sure how to do this, refer to
Section 20.2.4.6, “Tutorial: Databinding in ASP.NET using LINQ on Entities”
, which demonstrates
how to create a simple ASP.NET web site.
3. Add References to
MySql.Data
and
MySql.Web
to the web site project.
4. Locate the
machine.config
file on your system, which is the configuration file for the .NET
Framework.
5. Search the
machine.config
file to find the membership provider
MySQLMembershipProvider
.
6. Add the attribute
autogenerateschema="true"
. The appropriate section should now resemble
the following (note: for the sake of brevity some information has been excluded):
<membership>
<providers>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
...
connectionStringName="LocalSqlServer"
... />
<add name="MySQLMembershipProvider"
autogenerateschema="true"
type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
connectionStringName="LocalMySqlServer"
... />
</providers>
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...