Page view counter

Tableadapter configure wizard not generating update insert commands

Last post 02-20-2008 6:36 AM by swaino. 3 replies.

Sort Posts:

  • Tableadapter configure wizard not generating update insert commands

    01-30-2008, 6:06 AM
    • Loading...
    • swaino
    • Joined on 10-10-2006, 11:58 AM
    • Posts 461
    • Points 183

    I have this as my select statement when generating my tableadapter in the configure wizard: 

    SELECT     PurchaseItems.*, Stock.*
    FROM        
    PurchaseItems INNER JOIN
                         
    Stock ON PurchaseItems.StockItemId = Stock.stkId

    The update/insert/delete statements aren't being generated even though I've ticked the option to auto-generate them on the 'advanced options...' box in the wizard.

    I've done this before where I have had columns from another table in my tableadapter.

    So I'm not sure why this isn't working?? 

     

     

  • Re: Tableadapter configure wizard not generating update insert commands

    01-30-2008, 8:35 AM
    Answer
    • Loading...
    • ecbruck
    • Joined on 12-30-2005, 2:39 PM
    • Des Moines, IA
    • Posts 9,159
    • Points 85,497
    • Moderator
      TrustedFriends-MVPs

    This most likely has to do with the fact that you're using joins rather than subqueries. Check out the following tutorial.

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

    Thanks, Ed

    Microsoft MVP - ASP/ASP.NET

  • Re: Tableadapter configure wizard not generating update insert commands

    01-30-2008, 8:57 AM
    • Loading...
    • swaino
    • Joined on 10-10-2006, 11:58 AM
    • Posts 461
    • Points 183

    Ok thanks, I thought this might be the case but just wanted to confirm.

    I was sure I'd created table adapters in the past with JOINs and generated INSERT/UPDATE commands ok?!?

    What I might do is create Sprocs just for the insert/delete/update commands.

  • Re: Tableadapter configure wizard not generating update insert commands

    02-20-2008, 6:36 AM
    • Loading...
    • swaino
    • Joined on 10-10-2006, 11:58 AM
    • Posts 461
    • Points 183

     Just re-visited this problem and this quote from the above tutorial highlights the work-around...

    When working with relational databases, it is common for queries to pull their data from multiple, related tables. Correlated subqueries and JOINs provide two different techniques for accessing data from related tables in a query. In previous tutorials we most commonly made use of correlated subqueries because the TableAdapter cannot auto-generate INSERT, UPDATE, and DELETE statements for queries involving JOINs. While these values can be provided manually, when using ad-hoc SQL statements any customizations will be overwritten when the TableAdapter Configuration wizard is completed.

    Fortunately, TableAdapters created using stored procedures do not suffer from the same brittleness as those created using ad-hoc SQL statements. Therefore, it is feasible to create a TableAdapter whose main query uses a JOIN when using stored procedures. In this tutorial we saw how to create such a TableAdapter. We started by using a JOIN-less SELECT query for the TableAdapter’s main query so that the corresponding insert, update, and delete stored procedures would be auto-created. With the TableAdapter’s initial configuration complete, we augmented the SelectCommand stored procedure to use a JOIN and re-ran the TableAdapter Configuration wizard to update the EmployeesDataTable’s columns.

    Re-running the TableAdapter Configuration wizard automatically updated the EmployeesDataTable columns to reflect the data fields returned by the Employees_Select stored procedure. Alternatively, we could have added these columns manually to the DataTable. We will explore manually adding columns to the DataTable in the next tutorial.

Page 1 of 1 (4 items)