locked
Database access error in ASP.net RRS feed

  • Question

  • User-391533856 posted

    Hi. I'm Rakesh.

    I'm trying to use my ASP.net code for connecting my datatbase( Created using Microsoft Access 2007).

    There is no error in the code but when i execute it, the following is displayed:

    System.Data.OleDb.OleDbException: Cannot update.  Database or object is read-only.     
    And the code i used was:

    public void insert(string a, string b, string c)
    {
    string sExcelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="my path";Extended Properties=Excel 8.0;Persist Security Info = False";
    OleDbConnection con = new OleDbConnection(sExcelConnectionString);
    con.Open();
    OleDbCommand cmd = new OleDbCommand ("insert into Table1 values("+a+",'"+b+"','"+c+"')",con);
    cmd.ExecuteNonQuery();
    con.Close();
    }

    Somebody please help.

    I'll be glad if it is solved soon...

    Monday, April 8, 2013 12:19 AM

Answers

  • User1992938117 posted

    Hi,

    It seems that you .mdb file is read only, Right click on it then properties, remove read only attribute. If its not working then give the permission to current user as read/write (also for testing can give for everyone read/write permission) permission.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 8, 2013 1:02 AM

All replies

  • User1992938117 posted

    Hi,

    It seems that you .mdb file is read only, Right click on it then properties, remove read only attribute. If its not working then give the permission to current user as read/write (also for testing can give for everyone read/write permission) permission.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 8, 2013 1:02 AM
  • User-1716253493 posted

    Try use Microsoft.ACE.OLEDB.12.0 provider instead Microsoft.Jet.OLEDB.4.0 (if using 2007/2010 file format)

    http://www.microsoft.com/en-us/download/details.aspx?id=13255

    Monday, April 8, 2013 2:21 AM