我想为客户端用户编写一个Web应用程序,以便从客户端系统中选择一个文件
开始使用批量插入将该文件上传到服务器,我写了这个查询:
string filename = Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("~/") + filename);
String paht = Server.MapPath("~/") + filename;
string bulkInsertQuery = "BULK INSERT Table_1 from '" + paht + "' WITH( FIELDTERMINATOR = ',',ROWTERMINATOR = '\n',CODEPAGE = '1256'); ";
using (SqlConnection con = new SqlConnection(connection))
{
using (SqlCommand cmd = new SqlCommand(bulkInsertQuery, con))
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}//end of using
}//end using 1
但是当运行该代码时,我收到此错误:
{"Bulk load: An unexpected end of file was encountered in the data file.\r\nThe OLE DB provider \"BULK\" for linked server \"(null)\" reported an error. The provider did not give any information about the error.\r\nCannot fetch a row from OLE DB provider \"BULK\" for linked server \"(null)\"."}
发生了什么?我怎么能解决这个问题?谢谢。