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,100 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now