locked
Problem with AccessDataSource.update() RRS feed

  • Question

  • 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 = "<br /><span style='color:green;'>Kategorien er opdateret</span>";
    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
    • Moved by Michael Sun [MSFT]Microsoft employee Thursday, October 16, 2008 3:02 AM Off Topic for Visual C# General [loc] (Moved from Visual C# General to Off-Topic Posts (Do Not Post Here))
    Sunday, October 12, 2008 8:44 PM

All replies

  • I've tested the SQL in access, and it seems to be working. Also I've debugged the code, and all the parameters are set as they are supposed. 
    I just tried your suggestion and it returns an syntaxerror in SQL, so I don't think that's where the problem is, but thank you very much for the suggestion :)

    /Ole
    Sunday, October 12, 2008 9:03 PM
  • I don't have Access experience but in Sql Server when you add parameters, the column name (you have it) but also the parameter name: @name_de should be included in the string.

    You reacted too quickly for me. I deleted that post because I realized it was goofy, sorry. I am away from my computer, have no access to my codes and checking things on MSDN.
    AlexB
    Sunday, October 12, 2008 9:03 PM
  • Hi again :)

    If I run it in the immediate window, the updateParameters has been properly set, so I don't think thats the problem either. Also I'm doing similar operarions elsewhere in the website, and it works fine.. it's just this one bothering me :s

    /Ole
    Sunday, October 12, 2008 9:08 PM
  • Hello,

          The webpage issues, I recommend you create a new thread at ASP.NET Forums.   Visual C# General forum does not cover the C# issues related ASP.NET website and web applications. 

          Thanks,

    Best Regards,
    Lingzhi
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Thursday, October 16, 2008 3:02 AM
  • ok, I didn't know that :)

    I've moved it here: http://forums.asp.net/t/1336003.aspx
    Saturday, October 18, 2008 8:58 PM