Hello,
I have CSV file i want to upload the CSV file data to my table, With the help of file fileupload, below is my code
public void InsertAccounts()
{
con.Open();
SqlCommand cmd = new SqlCommand("BULK INSERT SN001CompanyTable FROM '" + System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName) + "' WITH (FIRSTROW = 2,FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')", con);
cmd.ExecuteNonQuery();
con.Close();
lblalert.Text = "Submitted";
}
After selecting file when i click on upload i am getting
Cannot bulk load. The file "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\CompanyData_Format (1).csv" does not exist.
my CSV is on desktop, i dont know how fileupload take correct path., Please help