Get the App
SLTechnology News&Howtos  ›  Database  › 

.net2.0 how to connect to the Mysql5 database configuration

Shulou Source: shulou.com Published: 2022-05-31 20:37:50 09月25日 Update

This article mainly introduces the .net2.0 how to connect Mysql5 database configuration, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

I have always liked Mysql, the main reason is: 1. The database is small. two。 The database is open source and free. 3. The database has many useful client tools.

4. Cross-platform. 5. Performance and functionality are relatively powerful (it is impossible to compare with those heavyweights). 6. Easy to migrate, deploy and install. So the small projects I do usually do.

Mysql is preferred. Recently, I have been using the combination of. Net + sqlserver05, but it suffers from sqlserver Enterprise Edition. The Standard Edition only supports server 03. My desktop is XP.

So very depressed, installed an Express, much less function. I don't like it either. It can't be unloaded even if it is unloaded. Finally, even consider using other people's Sqlserver2000 enterprises remotely.

Version. But because. Net also supports Mysql connections, I searched the Internet for the implementation and the tools I needed. It's really not very technical. It seems that I can consider it in the future.

The combination of .net + Mysql. There are a lot of information about this on the Internet, and I only record my own experience. No, for reference, just make a detour.

Download tool:

The connector/net5.0 download address of Mysql:

Http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-5.0.6.zip/from/pick

Download it and install it directly.

Once installed, add a reference to the project and you can use it.

The following code: the implementation function is to read a user table from Mysql and execute the stored procedure of Mysql. Examples are not difficult, but success is good. Local machine

It's all passed. Native environment: XP+Mysql5+VS05+C# (ASP.NET2.0)

The code is simple, mainly for testing:

Using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;using MySql.Data.MySqlClient Namespace ConnectMysql {public partial class _ Default: System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {if (! Page.IsPostBack) {MySqlConnection con = DB.createCon (); string sql = "select * from t_user"; MySqlDataAdapter mda = new MySqlDataAdapter (sql,con); DataSet ds = new DataSet () Mda.Fill (ds, "user"); this.GridView1.DataSource = ds; this.GridView1.DataBind ();}} protected void Button1_Click (object sender, EventArgs e) {MySqlConnection con = DB.createCon (); MySqlCommand cmd = new MySqlCommand ("getUsername", con) Cmd.CommandType = CommandType.StoredProcedure; con.Open (); try {MySqlDataReader dr = cmd.ExecuteReader (); this.GridView2.DataSource = dr; this.GridView2.DataBind (); con.Close () } catch (Exception ex) {ex.ToString (); con.Close ();}

The title is quite attractive, in fact. Net1.0 and Mysql are actually the same.

Thank you for reading this article carefully. I hope the article ".net2.0 how to connect to the Mysql5 database configuration" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!

Tags: Data database article function tool support configuration code enterprise project native reference combination clean powerful depressed successful download tool value first Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology vpn NVidia Huawei Microsoft