Results 1 to 6 of 6

Thread: How do I import a text file into a DataTable?

Threaded View

  1. #1

    Thread Starter
    Lively Member Christhemist's Avatar
    Join Date
    Sep 2016
    Location
    Nevada
    Posts
    116

    How do I import a text file into a DataTable?

    I keep getting this error: "The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data."

    Obviously I have checked if the file is open, rebooted, etc. It is not open and it has full permissions!


    Here is my code: (Highlighted is where the error is occurring)

    Code:
     
            Dim PathToUse As String = "C:\WORK\A_TEST\"
    
            Dim MyConnection As System.Data.OleDb.OleDbConnection
    
            Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
    
            MyConnection = New System.Data.OleDb.OleDbConnection _
                ("provider=Microsoft.ACE.OleDB.12.0;Data Source='" & PathToUse & "';Extended Properties=Text;")
    
            MyCommand = New System.Data.OleDb.OleDbDataAdapter _
                    ("select * from [CommaDelimitedFile]", MyConnection)
    
            MyCommand.TableMappings.Add("Table", "TestTable")
    
            MyCommand.Fill(AddressListDatatable)
    Last edited by Christhemist; May 18th, 2018 at 11:21 AM.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width