Reading text file using ADO.net

S

Simon Verona

Not sure if this is the best group... it may be better off in one of the ADO
groups, but I'm sure somebody here knows the answer:

I'm trying to load up a text file using ADO.net, as follows:

Dim TextConnectionString As String

TextConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=" & FilePath & ";" & _

"Extended Properties=""Text;HDR=NO;FORMAT=Delimited"""

Dim TextConn As New System.Data.OleDb.OleDbConnection(TextConnectionString)

TextConn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from " &
filename, TextConn)

Dim ds As DataSet = New DataSet("CSVFiles")

da.Fill(ds, filename)



When I run this, it fails at the "fill" statement with the error "Database
or object is read only".



The file in question can definitely be read and written (it's a short CSV
file). What have I done wrong???

Many thanks in advance.



Simon
 
C

Cor

Hi Simon,

I am also not sure if this is the wrong group, but I am sure that you are
missing a command.

Dim cmd As New OleDbCommand(sqlStr, Conn)
Dim da As New OleDbDataAdapter(cmd)

Not saying that I know of the rest works.

But maybe it was only this?

Cor
 
H

Herfried K. Wagner [MVP]

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top