📜  c# mysql 查询 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:57.386000             🧑  作者: Mango

代码示例1
MySqlConnection con = new MySqlConnection(connectionString);
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM customers",con);
MySqlDataReader reader = cmd.ExecuteReader();
    while (reader.Read())
    {
        //You can get values from column names
        Console.WriteLine(reader["customerName"].ToString());
          //Or return the value from the columnID, in this case, 0
        Console.WriteLine(reader.GetInt32(0));
    }
con.Close();