I have an issue where I am unable to upload a CSV file using C# sqlbulkcopy. C# code is correct, files are getting uploaded when in correct format. Tested it.
Reason: These csv files, may be, are not in valid format. Please see pic below, here you can see that the highlighted part is my column row and where the highlighting ends there starts a new data row which is not in new line. So, it is a comma separated value sheet but values are in a single line, which throws me error "The given ColumnName does not match up with any column in data source" while uploading .
Please click on image for larger view.
If I open it in excel and save it by pressing Ctrl+S, a popup opens and says that it is not valid CSV and when I click yes and close the sheet it asks to save and replace the file in destination. After saving it and then opening in notepad there I could see that the content is in now correct format which uploads successfully using C#. Like below image:
When I put cursor between Over40hrs and 200 (image 1) and press backspace once nothing happens, seems like there is some character. This is happening for all rows. Can we play with that character and save it in valid format ?
Is there any way by which I can save the contents in valid format when uploading in C# asp.net ? I couldn't find such question on internet. Please help.