Solved

Trying to use MS JET database engine to read delimited text file from C#.  Get error saying 'Cannot Update. Database or object is read-only'

Posted on 2008-06-10
3
1,111 Views
Last Modified: 2013-12-17
Hi,

Im trying to use MS JET database engine from C# to read a delimited text file.  I'm using the schema.ini file in the same folder as the file Im trying to read.

My connection string is: "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='text;HRD=No;FMT=Delimited';Data Soruce=c:\\temp\\inventory\\download"

the select query Im using is just "select * from abc.txt"

The file uses the '~' character as the delimter, so i have specified this in the schema.ini file using
Format=Delimited(~)

Other than the non-standard delimiter, i have used this connection string and select query to read in other delimited text files successfully

I'm not trying to update the file in any way, just to read from it.  Just in case though, i have checked to see that the read-only attribute for the file is not on.

I get an OleDbException saying 'Cannot Update. Database or object is read-only'.  Thing is, Im not trying to update anything.  

Anyone have any ideas ?
0
Comment
Question by:quan77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:cottsak
ID: 21756741
why dont you use a standard text driver or create a custom DataSet schema in .NET?
0
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 21758053
First, I'm a VB man, not C#.  I don't think that has any bearing on this issue, and the question's appeared in the VB.NET Zone, but I thought I ought to mention it.

You say 'the select query Im using is just "select * from abc.txt"'.  Is that precisely the case with the problem file?  Or are you, by any chance, trying to read a file with an extension other than ".txt"?

I ask because I've come across similar problems with files which - while being pure "text" files - have "unrecognised" extensions.  I stress "similar" because I'm not sure that I've been in exactly the scenario you describe.  But I think it's something that it may be worth you checking out.

In the Registry under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text

you will find an entry for DisabledExtensions and another one for Extensions.  Check if the extension you are using appears in either or both of the lists of values in those entries.  I cannot now recall, off-hand, which problems result from listing/non-listing in each.  But if the extension you are using is in the list/s, it's not the problem.  If they're not in the list/s, it might be the problem and, if you come back, I'll dig in the archives a bit to rediscover the details if necessary.

Roger
0
 

Author Closing Comment

by:quan77
ID: 31465989
Roger, your instinct about the file extension was dead on.  I was actually using a .app extension.  Changing it to .txt fixed the problem.  Thank you.
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question