Export (0) Print
Expand All
0 out of 4 rated this helpful - Rate this topic

How to: Add Global Queries to a Dataset 

Global queries are SQL queries that return either a single (scalar) value or no value. Typically, global functions perform database operations such as inserts, updates, deletes, and the aggregating of information, such as returning a count of customers in a table or the total charges for all items in a particular order.

You add global queries by running the TableAdapter Query Configuration Wizard from within the Dataset Designer.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To add a global query to a dataset

  1. Open a dataset in the Dataset Designer. For more information, see How to: Open a Dataset in the Dataset Designer.

  2. Drag a Query from the DataSet tab of the Toolbox onto an empty area of the Dataset Designer.

    The TableAdapter Query Configuration Wizard opens.

  3. Choose a connection for the query to use. You can either choose one from the list or create a new connection. If you create a new connection, you will have the option to save it to the application configuration file. For more information, see How to: Save a Connection String.

  4. Choose whether to use SQL statements or stored procedures.

  5. Choose the stored procedure to use or, on the Choose a Query Type page of the wizard, choose the type of query you want and then click Next.

  6. Provide a query that performs the desired task, for example, SELECT COUNT(*) AS CustomerCount FROM Customers.

    NoteNote

    Dragging a query directly onto the Dataset Designer creates a method that will only return a scalar (single) value. While the query or stored procedure you select may return more than a single value, the method created by the wizard will only return a single value. For example, the query might return the first column of the first row of the returned data.

  7. Complete the wizard; the query is added to the Dataset Designer. For information on running the query, see How to: Execute TableAdapter Queries.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.