none
VS 17 : VB.net : Dataset : TableAdapter : SQL statement RRS feed

  • Question

  • Good Morning,

    To solve the problem I had I drop and create a view on ms sql server

    I was wondering if there is a way to change the sql statement of a table adapter programmatically.

    Than you all

    dataset view

    Thursday, October 25, 2018 2:18 PM

All replies

  • There is zero reasons to drop and recreate your view.

    1. In SSMS (SQL-Server Management Studio), edit the view.
    2. Back in VS, data source window, select the view. select configure with data source window.
    3. If there for instance a new field e.g. as shown below, select it and finish up.
    4. Now from the data source window place the field onto the form.

    If you simply modified the SQL e.g. added UPPER no re-configuration is needed as done above.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, October 25, 2018 3:50 PM
    Moderator
  • Hello, 

    In your dataset_print.Design.cs (C#, VB - similar) you have  two namespaces:

    - <default app namespace>

    - <default app namespace>.dataset_printTableAdapters

    In the second namespace you have class wo_mainTableAdapter. This class have property Adapter and commands are available through the Adapter property.

                wo_mainTableAdapter da = new wo_mainTableAdapter();
                da.Adapter.DeleteCommand.CommandText = "DELETE wo_main WHERE 1 <> 1";


    Sincerely, Highly skilled coding monkey.

    Thursday, October 25, 2018 3:58 PM
  • "There is zero reasons to drop and recreate your view."

    I have a good one : Work Order data can be on a history table or current table, some times even on a archive table.

    the sales order linked to that work order can be open, or already paid, both data can be on different tables, etc, etc, etc.

    I use a view as a Report source.

    Thanks for answering my post

    john



    • Edited by Bre-x Thursday, October 25, 2018 4:37 PM
    Thursday, October 25, 2018 4:36 PM
  • Thanks!

    I will give it a try

    thanks for answering my post

    john

    Thursday, October 25, 2018 4:38 PM
  • Hi,

    Do you resolve the issue? If you resolve the issue, could you please mark the helpful as answer. it will be beneficial to other community.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 29, 2018 7:41 AM