[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1153
  • Last Modified:

Simple Gridview Update query on accessdatasource not working

I am trying to implement the scenario mentioned in 'http://aspalliance.com/539'. 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 'http://aspalliance.com/539' 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

0
AidenA
Asked:
AidenA
  • 3
  • 2
1 Solution
 
NazoUKCommented:
Have you added ID to the DataKeyNames of the Gridview?
0
 
AidenAAuthor Commented:
Yep it is there as in the picture.
Gridview1.JPG
0
 
AidenAAuthor Commented:
Here's the query as well
Gridview2.JPG
0
 
NazoUKCommented:
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.
0
 
AidenAAuthor Commented:
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!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now