Simple Gridview Update query on accessdatasource not working

Posted on 2008-11-19
Last Modified: 2012-08-14
I am trying to implement the scenario mentioned in ''. They say that you can't addrows using the gridview on an access database, and so you have to use the detailsview in association with the gridview as they mention in their article.

I can get everything to work, except for the update query. Forgetting about the detailsview, I still can't get the update query on the gridview to work. I can get for instance, the first query below to work, but the second query which uses a ? symbol in both cases doesn't update anything. Just doesn't work. However, the strange thing is that I downloaded and implemented the project defined in '' and it works perfectly. The query is exactly the same format and works fine. So, I can't for the life of me figure out what is wrong?

In fact, I basically used their objects and transferred the data from my table into theirs, deleting all their data of course and changing the queries to suit me... and it worked perfectly, the second query below worked fine! But, then I added the details view to it and it randomly stopped working again? Looks like this website won't allow me to attach the aspx page to show the problem. How to solve?

Any help would be greatly appreciated.

This works:


UPDATE [User Information] SET [User Name] = ? WHERE (ID ='1234')


This does not work:


UPDATE [User Information] SET [User Name] = ? WHERE (ID = ?)

Open in new window

Question by:AidenA
    LVL 15

    Expert Comment

    Have you added ID to the DataKeyNames of the Gridview?

    Author Comment

    Yep it is there as in the picture.

    Author Comment

    Here's the query as well
    LVL 15

    Accepted Solution

    Have you set the fields that aren't updated to read only?

    Also in your accessdatasource change the conflictdetection property. At the moment it's at compareallvalues, I'm not sure exactly what the setting will be but you want to turn this off.

    Author Comment

    Yes, you're right... thank god! I never would have figured that out. Both those things mean that nothing happens when you try to edit.

    It was just bad luck I put on the 'compareallvalues' selection because I read in another post to do that and it didn't make any difference because the query i ran it on had all properties set to readonly = false. My main query would have worked then actually since nothing is read only, all columns are used. But then when I tried the smaller query in the beginning and it was on overwritechanges it didn't work then either because i needed to set the other fields to read only! Round and round...

    Well, thanks for that anyway I was getting a bit worried!

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now