locked
Cannot update. Database or object is read-only RRS feed

  • Question

  • User1982060498 posted

    I migrated my asp application to asp.net . When i run I got an error like this.


    "System.Runtime.InteropServices.COMException: Cannot update.  Database or object is read-only."

    I am using access db. I can't find out the solution .. Please help.

    Thursday, May 6, 2010 6:58 AM

Answers

  • User1982060498 posted

    Hi,


       I corrected the error. When i moved the code block inside the function along with the <td> , i got correct result.


    I moved the code from asp using the migration assistant, and not copied the asp code directly to asp.net.

    Thanks,

    Mahesh 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 7, 2010 5:29 AM
  • User-1199946673 posted

    I moved the code from asp using the migration assistant, and not copied the asp code directly to asp.net.
     

    That's great, but what's is the advantage of moving to ASP.NET, but still use classic ASP code? In asp.net, simply drag a gridview (or other datacontrol) to the form, use tha database wizard to connect to a database and you'll have the same result, but with much more options, like sorting, paging, CRUD operations with no code whatsover. I stringly advice you to use ASP.NET the way it is designed, and forget the classic ASP way of doing things!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 7, 2010 7:31 AM
  • User1982060498 posted

    Hi,

    There is a speed issue in asp site . So we decided to move it to asp.net by using any tool and check whether there is any difference.


    And if its ok we done it with actual .net controls and methods.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 7, 2010 8:42 AM

All replies

  • User-1199946673 posted

    I think you're using the wrong connectionstring (most likely the old fashion classic ASP way). Please read this article how to connect to an Access Database in ASP.NET 

    http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET

    Also, make sure you set the right permissions on the folder where you put the database:

    http://www.mikesdotnetting.com/Article/74/Solving-the-Operation-Must-Use-An-Updateable-Query-error

    If this doesn't help, please show your code?

    Thursday, May 6, 2010 10:44 AM
  • User1982060498 posted


    Hi ,

     Thanks for the reply.

    I moved my *.mdb file to App_Code folder and also gave permissions . But still I am getting the same error.


    My connection string as follows:


    Dim cnnCRM As ADODB.Connection

    Dim cnnCRM As ADODB.Connection

    cnnCRM.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Solutions\Copy of crmASPNET\App_Data\crm.mdb;Persist Security Info=False")


    and I got the error in the  first <td>

    <tr>
    <td height="20"><%=func_module(rst_module.Fields("MODULE").Value)%></td>
    <td height="20"><a href="moduledelete.aspx?                     client=<%=i_client%>&module=<%=IIF(IsDBNull(rst_module.Fields.Item("MODULE").Value),      Nothing, rst_module.Fields.Item("MODULE").Value)%>">Delete</a></td>
    </tr>


    function func_module() is defined as follows


    Function func_module(ByRef i_client1 As String) As String
            Dim rst_module1 As ADODB.Recordset
            Dim qry_module1 As String
            Dim returnValue As String = ""
            rst_module1 = New ADODB.Recordset
            qry_module1 = "SELECT MODULENAME FROM MODULES WHERE MCODE = " & i_client1 & ""
            rst_module1.Open(qry_module1, cnnCRM, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, adCmdText)
            
            If Not rst_module1.EOF Then
                returnValue = IIf(IsDBNull(rst_module1.Fields.Item(0).Value), Nothing, rst_module1.Fields.Item(0).Value)
            End If
            Return returnValue
        End Function

       

    Friday, May 7, 2010 12:52 AM
  • User-1199946673 posted

    Moving from asp to asp.net involves a lot more than just copy and paste your old code! I think you should start reading and watching tutorials and video's  on this website to understand what ASP.NET is all about. Click on the Webforms menu on this page. An example video how to deal wth databases can be found here. It's using SQL Server Express (like most examples) but it will you a general idea of the new concept!

    An ASP.NET tutorial that uses Access can be found here. Chapter 3 is dealing about Access databases. Also read all other articles of Mike regarding Access and ASP.NET, among which the 2 I mentioned earlier! Other interesting articles are:

    http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access
    http://www.mikesdotnetting.com/Article/54/Getting-the-identity-of-the-most-recently-added-record
    http://www.mikesdotnetting.com/Article/68/An-ASP.NET-Search-Engine-with-MS-Access-for-optional-search-criteria
    http://www.mikesdotnetting.com/Article/76/80040E14-MS-Access-Syntax-Error-messages
    http://www.mikesdotnetting.com/Article/92/MS-Access-Date-and-Time-with-ASP.NET
    http://www.mikesdotnetting.com/Article/123/Storing-Files-and-Images-in-Access-with-ASP.NET
    http://www.mikesdotnetting.com/Article/75/Simple-Login-and-Redirect-for-ASP.NET-and-Access

    The last one shows you a simple login system using an Access database. However, ASP.NET also has a build in security system (membership provider). By default, this uses a SQL Express databasefile, but you can use it also with Access

    http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=404

    I think you've a lot of reading and watching to do, to understand the basics of ASP.NET. This might seem quit difficult, but once you understand it you'll never want to go back to the classic old way!!!

     

    Friday, May 7, 2010 4:24 AM
  • User1982060498 posted

    Hi,


       I corrected the error. When i moved the code block inside the function along with the <td> , i got correct result.


    I moved the code from asp using the migration assistant, and not copied the asp code directly to asp.net.

    Thanks,

    Mahesh 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 7, 2010 5:29 AM
  • User-1199946673 posted

    I moved the code from asp using the migration assistant, and not copied the asp code directly to asp.net.
     

    That's great, but what's is the advantage of moving to ASP.NET, but still use classic ASP code? In asp.net, simply drag a gridview (or other datacontrol) to the form, use tha database wizard to connect to a database and you'll have the same result, but with much more options, like sorting, paging, CRUD operations with no code whatsover. I stringly advice you to use ASP.NET the way it is designed, and forget the classic ASP way of doing things!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 7, 2010 7:31 AM
  • User1982060498 posted

    Hi,

    There is a speed issue in asp site . So we decided to move it to asp.net by using any tool and check whether there is any difference.


    And if its ok we done it with actual .net controls and methods.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 7, 2010 8:42 AM