locked
Issue Importing CSV Files RRS feed

  • Question

  • User-82210664 posted

    Hey I have this code

    Dim myDataset As New DataSet()
            Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "dynamic\uploadedLists\" & strFileName & ";" & _
            "Extended Properties=""text;HDR=Yes;FMT=Delimited(,)"";"

            ''You must use the $ after the object you reference in the spreadsheet
            Dim myData As New OleDbDataAdapter("SELECT * FROM [" & table & "$]", strConn)
            'myData.TableMappings.Add("Table", "ExcelTest")
            myData.Fill(myDataset)

    And I am getting the error , while the path is correct. Any Ideas ?

    'E:\mis\sitename\dynamic\uploadedLists\Sheet1.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.

    Friday, May 21, 2010 10:29 AM

Answers

All replies

  • User-1499529924 posted

    I'm sure there is prolem on file path.

    instead of this

    Request.ServerVariables("APPL_PHYSICAL_PATH") & "dynamic\uploadedLists\" & strFileName & ";"

    String strPath;

    strPath=Server.MapPath(Request.ServerVariables("PATH_INFO")) & "dynamic\uploadedLists\" & strFileName & ";"

    Respons.Write(strPath);

     

     

    Friday, May 21, 2010 10:34 PM
  • User937138743 posted

    You can use:

    string sPath= Server.MapPath("path");

    here is some link: it may help you to understand virtual path and relative path

    http://msdn.microsoft.com/en-us/library/ms178116.aspx

    http://www.plus2net.com/asp-tutorial/mappath.php


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 21, 2010 11:42 PM
  • User-744022866 posted

    Is it an excel file or csv file

    'E:\mis\sitename\dynamic\uploadedLists\Sheet1.csv'   - I think it should be excel extention. Please clarify

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 22, 2010 1:34 AM