By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,666 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,666 IT Pros & Developers. It's quick & easy.

Reading text file using ADO.net

P: n/a
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(TextConnectionSt ring)

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


Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Nov 20 '05 #2

P: n/a
* "Simon Verona" <ne**@aphroditeuk.com> scripsit:
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;" & _


Typical question for this group:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.