none
Invalid path error using ACE Oledb provider RRS feed

  • Question

  • I am trying to use OLEDB ACE provider to populate a dataset but when the program tries to open the connection I get

    'c:\regdata\icdata-f14.csv' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

    It is a valid path and the name is spelled correctly code is

      string FileName = @"c:\regdata\icdata-f14.csv";
            OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"text;HDR=Yes;FMT=Delimited\";");
            conn.Open();
    Is this a permissions issue or am I not specifying the file name correctly or something else?
    Wednesday, October 29, 2014 10:10 PM

Answers

  • Hello UCISteve,

    >>Is this a permissions issue or am I not specifying the file name correctly or something else?

    For reading a csv file, we just need to provide the directory path, in your case, it should be:

    string FileName = @"c:\regdata\";

    To do a query with the file, we write code as below:

    OleDbCommand cmd = new OleDbCommand("select * from S20141022.csv", conn);

    The “S20141022.csv” file is under the specified directory in the connection string.

    If this does not work for you, please feel free to let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 30, 2014 2:32 AM
    Moderator
  • Take the filename out of the path. For a .csv file, only the path to the folder where the file is located is specified as the Data Source. The .csv file is specified in the SQL SELECT statement.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, October 30, 2014 12:58 PM

All replies

  • Hello UCISteve,

    >>Is this a permissions issue or am I not specifying the file name correctly or something else?

    For reading a csv file, we just need to provide the directory path, in your case, it should be:

    string FileName = @"c:\regdata\";

    To do a query with the file, we write code as below:

    OleDbCommand cmd = new OleDbCommand("select * from S20141022.csv", conn);

    The “S20141022.csv” file is under the specified directory in the connection string.

    If this does not work for you, please feel free to let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 30, 2014 2:32 AM
    Moderator
  • Take the filename out of the path. For a .csv file, only the path to the folder where the file is located is specified as the Data Source. The .csv file is specified in the SQL SELECT statement.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, October 30, 2014 12:58 PM
  • That worked thanks
    Friday, October 31, 2014 10:48 PM