Results 1 to 9 of 9

Importing file name index.csv with adodb error

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Importing file name index.csv with adodb error

    Hi Guys,

    i have issues with importing "Index.csv" file name.
    (in attachment).

    Code to import this file:
    Sub RunSQLQueryForCSV
    
        Dim Conn As Object
        Dim RecSet As Object
        Dim SQLStatement As String
        
        Set Conn = CreateObject("Adodb.Connection")
        Set RecSet = CreateObject("Adodb.Recordset")
        
        fileDirPath = "D:\Pulpit\Newest Pull request\MyFile\"
        Debug.Print fileDirPath1
        TabName = "Index"
        Debug.Print TabName1
        
        SQLStatement = "Select * FROM " & TabName & ".csv AS T1"
    
        With Conn
             .ConnectionString = "Provider=Microsoft.ACE.OLEDB.16.0;" & _
               "Data Source=" & fileDirPath & ";" & _
               "Extended Properties=""Text;HDR=Yes;MAXSCANROWS=0"""
               Debug.Print "Provider=Microsoft.ACE.OLEDB.16.0;" & _
               "Data Source=" & fileDirPath & ";" & _
               "Extended Properties=""Text;HDR=Yes;MAXSCANROWS=0"""
        End With
    
        Conn.Open
    
        RecSet.Open SQLStatement, Conn
       ' RunSQLQueryForCSV = RecSet.GetRows()
       
       For i = 1 To RecSet.Fields.Count
            b = RecSet(i).Name
       Next i
       ' ActiveSheet.Cells.ClearContents
        '.Range("A2").CopyFromRecordset RS
        ActiveSheet.Range("A2").CopyFromRecordset RecSet
        Conn.Close
        Set RecSet = Nothing
        Set Conn = Nothing
    End Sub
    getting error "SYNTAX error in FROM clause".

    When i am changing this file name to "Index2.csv" it is read without any issues!
    Why?

    Please help,
    Jacek
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Connecting to CSV file via ADODB connection throwing error : no default driver name
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2020, 09:59 AM
  2. [SOLVED] Error importing data from csv file
    By GerPis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2018, 12:27 PM
  3. [SOLVED] ADODB.Connection Generating Error on File Located on Cloud
    By masouder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2017, 03:42 PM
  4. Error while importing sheets from other Excel files into one file
    By AadVissers in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-07-2015, 03:53 PM
  5. [SOLVED] Made big error importing text file with dates
    By excelaron in forum Excel General
    Replies: 3
    Last Post: 07-11-2012, 07:36 PM
  6. [SOLVED] Error importing txt file
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2012, 09:46 AM
  7. Error: during importing an excel file into an online system
    By aveeator in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 02-13-2011, 12:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1