[+/-]
Connector/Net enables developers to easily create .NET applications that require secure, high-performance data connectivity with MySQL. It implements the required ADO.NET interfaces and integrates into ADO.NET aware tools. Developers can build applications using their choice of .NET languages. Connector/Net is a fully managed ADO.NET driver written in 100% pure C#.
Connector/Net includes full support for:
Features provided by MySQL Server up to and including MySQL Server version 5.5.
Large-packet support for sending and receiving rows and BLOBs up to 2 gigabytes in size.
Protocol compression which enables compressing the data stream between the client and server.
Support for connecting using TCP/IP sockets, named pipes, or shared memory on Windows.
Support for connecting using TCP/IP sockets or Unix sockets on Unix.
Support for the Open Source Mono framework developed by Novell.
Fully managed, does not utilize the MySQL client library.
This document is intended as a user's guide to Connector/Net and
includes a full syntax reference. Syntax information is also
included within the Documentation.chm
file
included with the Connector/Net distribution.
If you are using MySQL 5.0 or later, and Visual Studio as your development environment, you may want also want to use the MySQL Visual Studio Plugin. The plugin acts as a DDEX (Data Designer Extensibility) provider, enabling you to use the data design tools within Visual Studio to manipulate the schema and objects within a MySQL database. For more information, see Section 17.2.3, “Connector/Net Visual Studio Integration”.
Connector/Net 5.1.2 and later include the Visual Studio Plugin by default.
MySQL Connector/Net supports full versions of Visual Studio 2005, 2008, and 2010, although certain features are only available in Visual Studio 2010 when using MySQL Connector/Net version 6.3.2 and later. Note that MySQL Connector/Net does not currently support Express versions of Microsoft products, including Microsoft Visual Web Developer.
Key topics:
For connection string properties when using the
MySqlConnection
class, see
Section 17.2.6, “Connector/Net Connection String Options Reference”.
User Comments
I'm using Visual Web Developer 2010 Express Edition (and Visual C# 2010 Express) with MySQL. This is what I did:
1 - Download and install MySQL connector(just to get MySql.Data.dll).
2 - VWD 2010 in the Solution Explorer add reference to MySql.Data.dll(usually in c:\program files\MySQL\MySQL Connector Net(your version here)\Assemblies\v4.0 or v2.0)
3 - In the web.config add your string connection:
<connectionStrings>
<add name="MySQLConnString" connectionString="Server=your_MySql_Server_IP;Port=3306;Database=databaseName;Uid=username;Pwd=yourpassword;pooling=false;" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
4 - In the code behind type in: "using MySQL.Data.MySqlClient;"
Now you can use it as in this example:
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds_temp = GetObjects();
ListBox1.DataSource = ds_temp;
ListBox1.DataTextField = "yourColumn";
ListBox1.DataValueField = "yourColumn";
ListBox1.DataBind();
}
protected static DataSet GetObjects()
{
DataSet ds_temp = Connection_cls.GetDataSetQuery("SELECT yourColumn FROM yourtable", null);
return ds_temp;
}
private static string getHostString()
{
string host = ConfigurationManager.ConnectionStrings["MySQLConnString"].ConnectionString;
return host;
}
public static DataSet GetDataSetQuery(string sql, ArrayList paramList)
{
using (MySqlConnection conn = new MySqlConnection(getHostString()))
{
try
{
conn.Open();
MySqlDataAdapter da = new MySqlDataAdapter(sql, conn);
da.SelectCommand.Parameters.Clear();
if (paramList != null)
{
for (int i = 0; i < paramList.Count; i++)
{
da.SelectCommand.Parameters.Add(paramList[i] as MySqlParameter);
}
}
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
finally
{
conn.Close();
}
}
}
Add your own comment.