尝试将 CSV 文件加载到 MySQL 数据库中,我得到了运行时间
Fatal error encountered attempting to read the resultset.
类似的问题在四月份被问到这里。我没有看到任何回复,但希望其他人已经看到了。这是来自调试器的命令:
"LOAD DATA LOCAL INFILE 'D:\\SANCentral\\Customer Files\\ibm\\70738\\0918\\Switch
Port.csv' INTO TABLE By_Switch FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\\r\\n' IGNORE 1 LINES"
这是 C# 代码:
string ConnectionString = String.Format(@"server={0};userid={1};
password={2};database={3}", server, user, passwd, database);
MySqlConnection sqlconnect = new MySqlConnection(ConnectionString);
sqlconnect.Open();
IEnumerable<FileInfo> files = this.InputFileListView.Items.Cast<FileInfo>();
string commandstring = String.Format(@"LOAD DATA LOCAL INFILE '{0}' INTO TABLE {1} FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES",
files.FirstOrDefault().ToString(), "By_Switch");
MySqlCommand cmd = new MySqlCommand(commandstring,sqlconnect);
cmd.ExecuteNonQuery();
我已验证数据库中的列名与传入 CSV 文件中的列名匹配。