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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complex SQL statement in VB.NET 7 31
jquery tab header text 1 22
How to extract certain lines from textfile and save them to another file? 6 26
Where is this file? 3 25
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

792 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