4 Using the Data Providers in Visual Studio : Use Scenarios for Data Provider Integration in Visual Studio

Use Scenarios for Data Provider Integration in Visual Studio
Because DataDirect Connect for ADO.NET data providers are integrated into Visual Studio, many typical data access tasks can be simplified. For example, after making the connection to the database, you can create queries and update the database using Query Builder.
The following scenarios are only a few of the ways you can take advantage of this integration:
Creating a Simple Query
The Query Builder can help you graphically design database queries.
To create a simple query:
1
2
Select the data source in Server Explorer. Then, right-click Tables and select New Query. The Add Table window appears.
The Tables tab of the Add Table dialog box, with the EMP table selected from the list of available tables.
3
4
Click Close to close the Add Table window.
5
The Table node in Server Explorer lists a number of tables. The Query area is contains a window with the EMP table columns, which are expanded in a separate pane below it. A SQL query based on the selected columns is below.
6
Click the Execute SQL button ( Execute SQL button ) on the tool bar.
The Query area is contains a window with the EMP table columns, which are expanded in a separate pane below it. A SQL query based on the selected columns and the results of the query are below.
7
Inserting Data Into a Table
You can connect to the database and use Query Builder to insert data into a table.
To insert data:
1
Establish a data connection (see “Creating a New Connection in Server Explorer”). Then, expand the data connection in Server Explorer.
A blank query pane is displayed. Below it, the SQL query pane contains the outline of a query, in this case, the words SELECT FROM.
2
Right-click Tables; then, choose New Query. The Add Table window appears.
The Tables tab lists the available tables. DEPT_TMP has been selected.
3
4
Click Close to close the Add Table window.
5
Select the Change Type button on the tool bar; then, select Insert Results from the drop-down list.
The Table node in Server Explorer lists a number of tables. The Query area is contains a window with the DEPT_TMP table columns, which are expanded in a separate pane below it. A SQL query based on the selected columns is below.
6
The DEPTNO and DEPTNAME columns have been selected. The SQL query reflects the choices: INSERT INTO DEPT_TMP (DEPTNO, DEPTNAME) VALUES (7,Marketing).
7
Click the Execute SQL button Execute SQL button on the tool bar. One row is added to the table.
8
Select the Change Type button Change Type button on the tool bar, and choose Select from the drop-down list.
9
Click the Execute SQL button Execute SQL button . The results are returned in the Results pane. In the following example, the Marketing department has been added to the DEPT_TMP table.
The Results area shows that Marketing has been added to the table as Department Number 7.