loading CSV-File in DataGridView via OleDbConnection - Error
Hello,
i have to write a homework for my university (deadline is tonight...) and this OleDbConnection is making me mad.
I want to load a .csv-File into a Dataset and then fill the DataGridView with the DataSet, but I dont get it to work! The Code is okay but there is always a runtime error when I try to load the File.
I am sorry, my error is in german, but I will try to translate it:
"System.Data.OleDb.OleDbException (0x80004005): 'C:\csvFilesFolder\test.csv' ist kein zulässiger Pfad. Stellen Sie sicher, dass der Pfad richtig eingegeben wurde und dass sie mit dem Server, auf dem sich die Datei befindet, verbunden sind."
--->
"System.Data.OleDb.OleDbException (0x80004005): 'C:\csvFilesFolder\test.csv' is no correct pathname. Please make sure if the path is correctly spelled and that you are connected to the server, on which the file is saved." (followed by 8 more error-rows)
I have a button that loads the path in a textbox and uploads the file into my dataset.
I do not use the variable "txtFileName" yet, for I want to make it work in a static way first - so dont be confused.
Re: loading CSV-File in DataGridView via OleDbConnection - Error
Your deadline has probably passed, but you may still be interested in the answer to your question...
When accessing CSV files that way, the Data Source must be the directory that contains the CSV file. Threfore your connection string needs to be changed to:
Bookmarks