1. Need to drive
Please download Mysqldrivercs-n-easyquerytools, the version of your choice is good
2. Project Import Driver
1) Add in quote
Choose
Light in the picture, OK.
3. Code block
Add header File
Using Mysqldrivercs;
Connect Database Code
mysqlconnectionstring tconnstr = new mysqlconnectionstring ("localhost", "Wxj", "Root", "", 3306); Mysqlconnection tconn = new Mysqlconnection (tconnstr.asstring); Tconn.open (); Open Connection string tcmd = "SELECT * from Wxj.stu;"; Command statement mysqlcommand cmd = new Mysqlcommand (tcmd, tconn); Executes the query command on the defined Tconn object mysqldatareader tReader = cmd. Executereaderex (); if (Treader.read ()) //read one record at a time { Response.Write (treader["name"]. ToString ()); } Tconn.close ();//Important! To close Treader.close () in time;
The rest of the logic is looking at your needs.
C # connect to MySQL Database