C#循环遍历mysql
/ MessageBox.Show("222", "大鹏提示"); string strcon = "server=bdm256830400.my3w.com;database=bdm256830400_db;uid=bdm256830400;pwd=sq901112;SslMode = none;"; MySqlConnection conn = new MySqlConnection(strcon); //2. 打开数据库 conn.Open(); //此处设置读取的超时,不然在海量数据时很容易超时 var c = new MySqlCommand("set net_write_timeout=9999999; set net_read_timeout=9999999", conn); c.ExecuteNonQuery(); MySqlCommand rcmd = new MySqlCommand(); rcmd.Connection = conn; rcmd.CommandText = @"SELECT `zqcode`,`wtjiage` FROM `dp_weituo`"; //设置命令的执行超时 rcmd.CommandTimeout = 99999999; var myData = rcmd.ExecuteReader(); while (myData.Read()) { var f1 = myData.GetInt32(0); var f2 = myData.GetString(1); MessageBox.Show(f1.ToString(), "大鹏提示"); MessageBox.Show(f2, "大鹏提示"); }