As a server, database operations are inevitable. How does C # perform operations? This program uses various methods in the MySQLDriverCS namespace. This is relatively simple, so the premise is that you need to install this stuff. After the installation is complete, there is an important step to reference it.
Right-click to reference
Select Add reference, find MySQLDriverCS. dll, and click OK.
Then use
using MySQLDriverCS;
In this way, you can use it.
The usage is as follows:
Define the link string
string connstr = "Data Source=chatsys;" + "Password=root;User ID=root;Location=localhost;server=localhost;Charset=utf8";
Create link and open link
MySQLConnection conn = new MySQLConnection(connstr); conn.Open();
Execute an operation
string cmd = "select * from t_userinfo where F_State=1"; sqlcmd = new MySQLCommand(cmd, conn); MySQLDataReader anscmd = sqlcmd.ExecuteReaderEx();
If any result is returned, the result is as follows:
while (anscmd.Read()) { streamWriter[i].WriteLine((anscmd.GetString(anscmd.GetOrdinal("F_Name")))); streamWriter[i].Flush(); }
In this way, we can operate MySQL Data.
Previous: http://www.bkjia.com/kf/201312/261981.html