[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
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,119 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 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 19 hours left to enroll

834 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