I almost always use SQL connection strings, so when it came to reading a text file using ADO I wasn't sure what options I needed to specify. I went searching and found this site. Specifically for text files I looked here. It turns out that it works. I'm using this to import a CSV into a SQL server to do more intense operations on it. Thanks to Justin for pointing me in this direction.
Here's some sample code that works. This is just sample code... make sure you always use a try,catch, finally around a db connection to verify that it closes.
Dim connectionString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""text;HDR=Yes;FMT=Delimited;""", path)
sourceConnection = New OleDbConnection(connectionString)
sourceConnection.Open()
Dim dataAdapterSource As New OleDbDataAdapter(String.Format("Select * from {0}", filename), sourceConnection)
posted on Thursday, August 26, 2004 9:44 PM