1.14. Connecting to a Text File

Problem

You want to use ADO.NET to access data stored in a text file.

Solution

Use the OLE DB .NET data provider.

The solution creates and opens a connection to a text file using the OLE DB .NET data provider. Information about the connection is displayed.

The C# code in Program.cs in the project ConnectTextFile is shown in Example 1-15.

Example 1-15. File: Program.cs for ConnectTextFile solution

using System;
using System.Data;
using System.Data.OleDb;

namespace ConnectTextFile
{
...