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

Discussion in 'ASP .Net' started by tom, Jul 11, 2007.

  1. tom

    tom Guest

    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)
     
    tom, Jul 11, 2007
    #1
    1. Advertising

  2. tom

    ahaskins

    Joined:
    Jul 13, 2009
    Messages:
    1
    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?
     
    ahaskins, Jul 13, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2ZQ==?=

    The Microsoft Jet database engine cannot open the file

    =?Utf-8?B?RGF2ZQ==?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    971
    =?Utf-8?B?RGF2ZQ==?=
    Aug 5, 2005
  2. =?Utf-8?B?TmVhbA==?=
    Replies:
    3
    Views:
    41,693
    Paul Clement
    Sep 2, 2005
  3. Morten Wennevik
    Replies:
    1
    Views:
    3,136
    Morten Wennevik
    Oct 31, 2005
  4. Jas
    Replies:
    1
    Views:
    966
    Patrice
    Jan 25, 2010
  5. snazzy
    Replies:
    2
    Views:
    262
    Bob Barrows [MVP]
    Nov 7, 2008
Loading...

Share This Page