當我試圖從txt文件插入數據到mysql表中時,我收到了這個錯誤。我嘗試了整個列表,只有一個項目,使用csv,甚至刪除了「」,並創建一個只有一個字段的新表格,但問題在30秒後仍在繼續。在我的txt中有一個我需要在表格的1個字段中插入的數字列表,儘管表格有三個不同的字段。先謝謝你。嘗試讀取結果集時遇到致命錯誤。 MySQL Asp.Net
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUploadControl.HasFile)
{
try
{
if (FileUploadControl.PostedFile.ContentType == "text/plain")
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
StatusLabel.Text = "Upload status: File, "+filename+" uploaded!";
string dir = Server.MapPath("~/") + filename;
string strcon = "SERVER = 000.000.000.00; " + "DATABASE=fakedb;" + "UID=fakeid;" +"PASSWORD=fakepass;";
Response.Write(dir);
MySqlConnection con = new MySqlConnection(strcon);
con.Open();
MySqlCommand cmd = new MySqlCommand("LOAD DATA LOCAL INFILE '" + filename + "' INTO TABLE Cuenta_Test LINES TERMINATED BY '\n\r'", con);
cmd.ExecuteNonQuery();
con.Close();
}
else
StatusLabel.Text = "Upload status: Only txt files are accepted!";
}
catch (Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}