gpt4 book ai didi

mysql - c# 如何解决错误 mysql 使用的命令不允许 1148?

转载 作者:行者123 更新时间:2023-11-29 15:26:23 25 4
gpt4 key购买 nike

我正在从 C# 执行 SQL 查询,但收到错误:MySql.Data.MySqlClient.MySqlException:“此 MariaDB 版本不允许使用所使用的命令”任何帮助/指示将不胜感激。

这是我的代码:

    private bool SaveCsvLines(string strFileName)
{
bool bResult = false;
if (ConnectToDatabase())
{
// Here we load the string variable with the SQL we want to run
string strLineInsert = "LOAD DATA LOCAL INFILE " +
"'" + strFileName + "' " +
"INTO TABLE pfetest1.maerskInvoiceLine " +
"FIELDS TERMINATED BY ',' " +
"LINES TERMINATED BY '\r\n' " +
"IGNORE 1 LINES " +
"(container, " +
"size, " +
"vessel, " +
"portOfLoad, " +
"porCityCode, " +
"portOfDischarge, " +
"podCityCode, " +
"postCode, " +
"invoiceNo, " +
"SET createdTimestamp = NOW(), " +
"createdUserId = 1, " +
"updatedTimestamp = NOW(), " +
"updatedUserId = 1, " +
"headerId = " + m_iFileId + ", " +
"eta = STR_TO_DATE(@eta, '%d/%m/%Y')";

//Now we execute that statement
MySqlCommand command = new MySqlCommand(strLineInsert, con);
bResult = (command.ExecuteNonQuery() == 1);
}
return bResult;
}

最佳答案

改用 MySQLBulkloader。这样我就可以先定义列等,然后输入数据。

关于mysql - c# 如何解决错误 mysql 使用的命令不允许 1148?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59054962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com