我正在使用http://zetcode.com/db/mysqlcsharptutorial/上的教程,我相信我已经完全按照这些步骤进行操作,但是我遇到了这些错误。我已将 MySql.Data、MySql.Data.Entity 添加到引用中,但它仍然不允许我使用它。我已经用谷歌搜索了这个问题,似乎无法得到明确的答案。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;
using MySql.Data.Entity;
using MySql.Data.Common;
using MySql.Data.Types;
using System.Configuration;
using System.Data.Common;
namespace Practice
{
public class Example
{
public static void Main()
{
string cs = @"server=111.111.11.111; userid=11111111;password=111111;database=anydatabase";
MySqlConnection conn = null;
try
{
conn = new MySqlConnection(cs);
conn.Open();
MySqlConnection cmd = new MySqlConnection();
cmd.Connection = conn;
cmd.CommandText = "INSERT INT0 players(Anyone) VALUES(@Anyone)";
cmd.Prepare();
cmd.Parameters.AddWithValue("@Name", "Anyone New");
cmd.ExecuteNonQuery();
}
catch (MySqlException ex)
{
Console.WriteLine("Error: (0)", ex.ToString());
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
}
}