aspx操作mysql_C# 连接 MySQL 并进行数据库操作(入门篇)(How to Connect to MySQL Using C#)...

Now the following steps will show how to connect to a MySQL database using C#.

Step 1

Open MySQL Admin page and create a new database.

844c6d7c0da3cf90b791023fc699751e.png

Step 2

After creating the new database, create a new table.

2490128479142766c7c043cb1b07e3b8.gif

Step 3

After 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)).

0e8b3d24b416d704374c5d16141cfda6.png

Step 4

Add namespace to the project.

3e4f51a86d725c4bc96963dafbf3cf56.gif

e3f819871a24fdcc7e520f0769bc7974.gif

Step 5

Create a MySQL connection string.

2e1d452636990bfea82305b3a088145b.gif

Step 6

The following code will insert the data into MySQL table.

47c6c1c3a83255080c0190e3fe154d60.gif

Step 7

The following function will load the data from the table and bind it into a GridView.

8396697be87122f8a03824b5cf7be079.gif

Step 8

The final result is shown on the window form:

8b8afccf11f22bb9cfa147cf9f55f300.png

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值