Static void main (string [] ARGs) {console. writeline ("--------"); string myconn = "database = 'test'; Data Source = localhost; user id = root; Password = 123456; charset = utf8 ;"; // The SQL statement to be executed string MySQL = "select * from users"; // create a database connection mysqlconnection myconnection = new mysqlconnection (myconn); myconnection. open (); // create the mysqlcommand object mysqlcommand mycommand = new mysqlcommand (MySQL, myconnection); // use the executereader () method of mysqlcommand to construct the datareader object mysqldatareader myreader = mycommand. executereader (); // int size = 1024; // int sizecnt = (INT) math. ceiling (double) DataGrid. rowcount/(double) 2000); streamwriter write = new streamwriter ("F: \ test.csv", false, encoding. default, 1024*4); write. write ("ID" + "," + "user_name" + "," + "user_passwd"); write. writeline (); While (myreader. read () {string TEM = myreader. getint32 (0) + "," + myreader. getstring (1) + "," + myreader. getstring (2); write. writeline (TEM);} write. flush (); write. close (); myreader. close (); myconnection. close ();}