ASP.NET use SqlConnection connect MySQL ASP.NET use SqlConnection connect MySQL asp.net asp.net

ASP.NET use SqlConnection connect MySQL


SqlConnection is for SQL Server. You need MySqlConnection - this is not part of the .NET Framework, so you will have to download it and reference it in your project. You can then create a MySqlConnection object and connect to MySQL in your application:

MySqlConnection connection = new MySqlConnection(myConnString);

You will also have to use the MySqlCommand object rather than the SqlCommand object.

http://dev.mysql.com/doc/refman/5.0/es/connector-net-examples-mysqlconnection.html


as Darren seid "SqlConnection is for SQL Server."you need to install MySql.Data from NuGet: mySql.Data

also you can use Install-Package MySql.Data in your Package Manager Console

then you can create MySqlConnection object and connect to your database:

var cnn = new MySqlConnection("my Connection String");


Not that I know of, and even if it would, why would you want to? You are using a connection object specifically created for Microsoft SQL Server, so it wouldn't connect in the same fashion MySQL does.

For accessing a MySQL database, you should use the MySQL .NET connector which you can find here.