views:

2018

answers:

4

Hello -

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

+1  A: 

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

Doh! Thanks for pointing out the obvious...
DaveN59
A: 

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!

Thanks for the link to the article. However, my problem (and maybe yours, as well) is simpler than that. All I had to do was define primary keys and a relationship in the SQL Studio designer, and VS liked it just fine. I don't know what your data looks like, but VS can get quite a bit of info from SQL Server -- or not, apparently.
DaveN59
A: 

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

Too much work! :) That's essentially what I did do to get it working. However, it worked a lot slicker and cleaner, without manually changing anything, when I defined primary keys and relations in the database -- VS2008 figured out how to do what it needed to do from that information, with no manual intervention...
DaveN59
You got this solution to work for MS Access? I'm having this exact issue and I'm trying to get your method to work.
Matt Flowers
A: 

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.

George