?
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
Medium Priority
?
1,114 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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