By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

Issue with importing CSV file using JET. Error Message: 'Cannot update. Database or object is read-only. '

P: n/a
tom
When I try to read in a csv file it gives me this error message.
'Cannot update. Database or object is read-only.' If I change the
extension to txt it processes just fine. I have googled all sites on
this and I haven't found anything to help. (tried registry stuff,
reinstall .NET 2.0, patches). This just broke out the blue too which
is weird because it was running fine on our server on monday but now
it pukes. Here is the code.

public DataTable getCSVtable(string inFile, string header)
{
FileInfo diFile = new FileInfo(inFile);
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + diFile.DirectoryName
+ ";Extended Properties=\"text;HDR=" + header +
";FMT=Delimited\";";
OleDbConnection csvFile = new OleDbConnection(strCon);
csvFile.Open();
OleDbDataAdapter oCmd = new OleDbDataAdapter("SELECT *
FROM [" + diFile.Name + "]", csvFile);
DataSet myDataset = new DataSet();
oCmd.Fill(myDataset);
csvFile.Close();
DataTable myTable = myDataset.Tables[0];

return myTable;
}

Here is the stack trace with the error message in front:
Cannot update. Database or object is read-only. at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

Jul 11 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.