Search code examples
vb.nettextoledb

Query a text file


Hey all is there any way to query a text file using OleDB or something else. Just need to be able to query it like below:

    Dim connectionString As String
    connectionString = "Provider=?????????????????;Data Source=C:\Data\theFile.txt"
    connection = New System.Data.OleDb.OleDbConnection(connectionString)
    connection.Open()

    Dim sqlString As String
    sqlString = "SELECT * FROM Categories"
    Dim command As New System.Data.OleDb.OleDbCommand(sqlString, connection)
    'Retrieve data 
    reader = command.ExecuteReader()

Any help would be great!


Solution

  • Try like this.

    con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|;Extended properties='text;HRD=yes;FMT=Delimited'")
    

    http://www.connectionstrings.com/textfile