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)
'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)