locked
Problem with AccessDataSource.update() RRS feed

  • Question

  • User2068324065 posted

    Hi guys,

    This is my first post at the forum, so please excuse me if something is not right ;) The reason for writing here is that I have encoutered a problem with AccessDataSource.update(), the actual code looks like this:

    AccessDataSource ds = new AccessDataSource();
    ds.DataFile = "~/App_Data/db.mdb";
    ds.UpdateCommand = "UPDATE productCategory SET category = @name, parentCategoryId = @parentCategoryId, category_de = @name_de, category_en = @name_en WHERE id = @cid;"; ds.UpdateParameters.Add("name", Navn_textBox.Text);
    ds.UpdateParameters.Add("parentCategoryId", categoriesDropDown.SelectedValue.ToString());
    ds.UpdateParameters.Add("name_de", NavnDe_textBox.Text);
    ds.UpdateParameters.Add("name_en", NavnEn_textBox.Text);
    ds.UpdateParameters.Add("cid", updateIdHidden.Value.ToString());
    ds.Update();

    Running this on local machine results in the following error: 'ds.SqlCacheDependency' threw an exception of type 'System.NotSupportedException'

    Running it on a webserver results in the following error:
    Operation must use an updateable query. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query. Source Error:

    Line 145:
    Line 146:
    Line 147: ds.Update();
    Line 148: msg.Text = "Kategorien er opdateret";
    Line 149: Source File: e:\Web\dir\filename.aspx.cs
    Line: 147 Stack Trace: [OleDbException (0x80004005): Operation must use an updateable query.]
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +404 System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +721 System.Web.UI.WebControls.SqlDataSource.Update() +17 admin_categories.gemKatButton_Click(Object sender, EventArgs e) in e:\Web\dir\filename.aspx.cs:147 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

    Can anyone help me on this?

    /Ole Kallehave

    Saturday, October 18, 2008 4:20 PM

Answers

  • User-1199946673 posted

    Welcome,

    Everything is right. But if you look in this forum, on top is a topic with exactly the problem you have, since this is one of the most asked questions! The answer can be found here

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 18, 2008 4:59 PM
  • User-821857111 posted

    But what if I don't have rights to change the folder permission on the server?

    Then you are stuffed. Get a hosting account where they give you those rights.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 20, 2008 3:58 AM

All replies

  • User-1199946673 posted

    Welcome,

    Everything is right. But if you look in this forum, on top is a topic with exactly the problem you have, since this is one of the most asked questions! The answer can be found here

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 18, 2008 4:59 PM
  • User2068324065 posted

    Thanks :)

    I'll try it out. But what if I don't have rights to change the folder permission on the server?

     /Ole

    Saturday, October 18, 2008 5:36 PM
  • User-821857111 posted

    But what if I don't have rights to change the folder permission on the server?

    Then you are stuffed. Get a hosting account where they give you those rights.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 20, 2008 3:58 AM