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

T

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.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet 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)
 
Joined
Jul 13, 2009
Messages
1
Reaction score
0
Solution?

In doing some research it seems to be that any file other that *.txt or *.csv will cause this. Were you able to find a workaround?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top