如果对任何人有帮助,请通过以下方法修复该问题。
public static void MySqlCSVImport(string Filename, string Table, string Server, string Database, string User, string Password, string Port)
{
try
{
//enclosed by '"'
string FixFilePath = Filename.Replace(@":\", ":\\");
string c = "'" + "\\n" + "'";
string d = ";";
string connectionString = "server=" + Server + ";database=" + Database + ";User Id=" + User + ";password=" + Password + "";
MySqlConnection mySqlConnection = new MySqlConnection(connectionString);
mySqlConnection.Open();
string Query = "load data local infile" + " " + "'" + FixFilePath + "'" + " " + "into table" + " " + Table + " FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY" + " " + c + d;
MySqlCommand cmd = new MySqlCommand(Query, mySqlConnection);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}