How to Connect to MySQL Using C#
2013-11-30 10:53
489 查看
How to Connect to MySQL Using C#By Ravindra T C,17 Jul 2012
IntroductionThis article shows you how to connect to a MySQL database using the MySQL Connector for .NET. I will also show you how you can update MySQL database records using C#.PrerequisitesInstall Visual Studio 2008 or Visual Studio 2010Install MySQL database on your local machine MySQL database admin tool that allows you to create a database and run SQL statements. I am using phpMyAdmin which is a web interface. Download and install MySQL Connector. Getting StartedRun the XAMPP application and it will automatically install Apache server, MySQL database, and FileZilla. After installing check whether these services are running or not. The following XAMPP control panel shows which of those services are currently running.Now the following steps will show how to connect to a MySQL database using C#. Step 1Open MySQL Admin page and create a new database.Step 2After creating the new database, create a new table.Step 3After creating the new table, open Visual Studio and click on New Project and name the project. It will open the new project, then click on Solution Explorer (F4), right click on “Reference” to add a new reference into the project. Reference those two.dll files to the project (MySql.dll (Win apps), MySql.web.dll (Web apps)). Step 4Add namespace to the project.Step 5Create a MySQL connection string.Step 6The following code will insert the data into MySQL table.Step 7The following function will load the data from the table and bind it into aGridView. Step 8The final result is shown on the window form:LicenseThis article, along with any associated source code and files, is licensed underThe Code Project Open License (CPOL) About the AuthorRavindra T C Software DeveloperL&T IES Mysore India I'm a software developer. I spent most of the time in learning new technologies. I've a keen interest in client-side technologies especially JavaScript and Jquery it is the most beautiful language ever seen. I like sharing my knowledge and written some non-popular articles. I believe in quality and standards but blames myself for lagging them. I believe in small things and they makes me happy! Article Top |
相关文章推荐
- How to connect Sybase DB using C#
- Docker - How to Connect to a MySQL Running Container Using MySQL Command Line Client
- Using Scala with JDBC to connect to MySQL
- mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.
- How to get simple dispatch from this.props using connect w/ Redux?
- php 5.3:connection failed:SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using old auth
- How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
- SQL: How to get a series of dates in sql using connect by
- How to Install MySQL Database Using Yum groupinstall on CentOS
- C# Tips 1------How to scale text using Textrenderer
- How to Make Dynamic Hyperlinks Using C# in ASP.NET
- mysqlnd cannot connect to MySQL 4.1+ using the old insecure【解决方法】
- How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
- mysqlnd cannot connect to MySQL 4.1+ using the ...
- How to install LAMP (Apache, PHP and MySQL in Linux) using Yum
- 在万网虚拟主机上连接数据库出错mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication
- How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C# .NET
- 转 -- How To Repair Corrupted MySQL Tables Using myisamchk
- How to synchronize access to a shared resource in a multithreading environment by using Visual C#
- How to Make Dynamic Hyperlinks Using C# in ASP.NET