none
Schema.ini file not importing text successfully RRS feed

  • Question

  • I am trying to pull a text file into a recordset.  Here is the code I am using:

        connTextFile.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & Folderpath & ";" & _
            "Extended Properties=""text;HDR=YES;FMT=FixedLength"""
        If FileTest.Size > 0 Then
            SQLStatement = "Select * FROM [" & strFilename & "]"
            
            TempRecordset.Open SQLStatement, connTextFile, adOpenDynamic, adLockReadOnly
            Debug.Print TempRecordset.RecordCount
    

    RecordCount should be returning 3, because there are three lines on this file. 

    And here is the ini file: 

    [Header.txt]
    ColNameHeader=False
    Format=FixedLength
    TextacterSet=ANSI
    MaxScanRows=0
    CharacterSet=OEM
    Col1="Record_Indicator" Text Width 1
    Col2="Date_Created" Text Width 8
    Col3="Time_Created" Text Width 6
    Col4="Employer_ID" Text Width 7
    Col5="Employer_Name" Text Width 50
    Col6="Header_Memo" Text Width 25

    I've tried a number of different ways of declaring the columns including using "Char" instead of "Text" and  single, double, and no quote marks around the column names.  The name of the file I am trying to pull from IS called Header.txt, Header.txt is being passed to the Function correctly, and both the Schema.ini file and the text file are in the same folder.  Everything is using vbCrLf as the carriage return, if that makes any difference. I'm at my wits end with this.  Does anybody see what I'm doing wrong?

     

    Saturday, September 6, 2014 2:39 AM