Question

I am fighting a recalcitrant VS2008 DataSet designer, it seems. I have been trying to do what seems to be a simple 2-table dataset solution, where one table is simply the textual meaning for an integer value stored in the other table. Basic data design 101.

Table1
CharField1
CharField2
IntForeignKeyField1
etc

Table2
IntPrimaryKey1
ValueForKeyField

That doesn't really affect the problem I am having, I don't believe, as I am not wanting to do anything but read the values in from the second table so I can choose them in a DataGridViewComboBoxColumn in the client -- I will never edit them on the client. But, I digress.

Since this lives in a web service, and I wanted a strongly-typed dataset delivered to the clients of this web service, I decided to use the DataSet Designer to build the TableAdapters and all the plumbing, thinking it might be less work and easier to maintain.

So, I created the pretty boxes and edited the select statements, instructing the designer to create all Insert, Update and Delete commands for the table adapter to use. It happily obliged, informing me that everything was done as I asked.

When I tried to use the Update statement, however, I got an error saying there was no valid Update statement! After some fruitless searching around for people with similar woes on the web, I dug into the XML for the dataset. Sure enough, no Update statement, and no Delete statement, either.

I tried completely deleting and recreating the DataSet from the project, with the same results. No Update or Delete statements were created, even though it was reported as done.

I ended up building the Update statement XML by hand, by inspecting another designed dataset from another project, so the web service is now working. However, I have no faith whatsoever my changes would last through an edit initiated from the designer, and I am stumped as to why it is not working. Any ideas?

Thanks for any feedback, Dave

Was it helpful?

Solution

could it be that there is no unique primary key defined for the table?

OTHER TIPS

I am having the same problem. The TableAdapter does not work properly when using fields from more than one table. I was able to re-create the solution from the following article: "Updating the TableAdapter to Use Joins".

http://www.asp.net/learn/data-access/tutorial-69-vb.aspx

The solution involves creating your own Select/Update/Insert/Delete procedures. Unfortunately, while I was able to follow the solution for an sqlserver database, I am still not able to get it to work for my local Access database. All the stored procedure options are grayed out.

Good Luck!

I think I found the solution. 1) Create a TableAdapter for the main table only and copy the TableAdapter UPDATE procedure (stored in TableAdapter properties window) 2) Change the SELECT query in the"TableAdapter Configuration Wizard Query Builder" to include fields from both tables and the join. 3) Paste the old UPDATE procedure into the now blank TableAdapter UPDATE procedure. 4) After creating DataGridView, you can display fields from both tables and update the main table. Repeat steps for INSERT & DELETE commands.

If your goal is to update both tables, try looking into TableAdapter Parent/Child update information on the web. Here is a good link: http://blogs.msdn.com/bethmassi/archive/2009/05/14/using-tableadapters-to-insert-related-data-into-an-ms-access-database.aspx

Just ran into the same basic problem. I told the data designer to create all insert, update, delete statements. When I went to update one of the tables there was no update available. I finally went into the .xsd file created by the data designer (just double clicked to open it in the IDE). I then right clicked on the title bar of the table that had the issue and selected the configure option. From there I clicked the 'Advanced Options' button, then selected the 'Generate Insert, Update, Delete Statements' option. After pressing Okay I checked my project and the update was available for the table adapter.

What George suggested is great. We need to enable the 'Generate Insert, Update, Delete Statements' option.

However in VS2013, using unnecessary table qualifiers in the selete statement may upset the IDE and result in the generation of SELECT and INSERT statements only. Just remove this qualifiers and it should be alright. Make sure you have a unique PK too.

If you need to use complicated fill like applying filter to return certain rows of the table only, you can fill the data table using specific select statement in the form load event. In that way, the generated INSERT, UPDATE and DELETE statements will still work, because DELETE and UPDATE work on the PK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top