How to update Query tables vs just tables

mrRogers

Well-known member
Joined
Jan 23, 2016
Messages
45
Programming Experience
3-5
From a DatagridView I can update back to an access table but I can not to a access query table. Update is not a member of that adapter. Anybody understand this?
 
What is a "query table"? Is that actually a thing or is that just a term that you made up? I just Googled "access query table" and I didn't get any results that actually mention a "query table".

Are you actually just talking about a query, which is the Access equivalent of a stored procedure? If so then the reason that you can't update it is that it doesn't contain any data. A query simply retrieves data from one or more tables and/or other sources. The only update that makes sense is to update those sources. You can add your own UpdateCommand, etc, to do that.
 
I guess that makes sense. In Access I created a query from two associated tables. may adapter for the grid actually .fills from this query just like a table. I thought it might accept .update as well but sounds like no.
 
Yeah, it's not a query table but just a query. It doesn't contain any data, just SQL code to get data, so there's not actually anything to update.

Presumably you want to write data changes back to one or more of the source tables for the query. If you're working with a typed DataSet then you can add your own INSERT, UPDATE and DELETE commands to your table adapters in the DataSet designer. The thing is, Access only lets you modify one table per command, so you won't be able to update more than one source table per adapter. If you want to update more then you'll have to create multiple table adapters in the designer and configure each one to update one table. You'd then have to call Update once on each to update each table. If you're doing that then you need to make sure that AcceptChanges doesn't get called on the DataTable until the end of the operation, so you need to set AcceptChangesDuringUpdate to False on all but the last adapter you use at run time.
 
Back
Top