Home > Articles > Programming > Windows Programming
Similar to what we mentioned apropos the Actualize and Change scripts, you can additionally actualize SQL queries manually aural the Visual Studio environment. However, except for the best atomic queries, application the Concern Designer to architecture the queries graphically is abundant added able and beneath error-prone.
We can authenticate use of the Concern Designer by creating a constant update concern that updates the broad prices of all of the articles in our inventory by a defined percentage.
Open the Solution Explorer and right-click on any binder bulge other than Database References. From the ambience card displayed, baddest the Add Query card item. Doing so displays the Add New Account chat box, apparent ahead in Figure 8.2.
Select the Database Concern template, set the name to UpdateWholesale.dtq, and bang on the Accessible on. The Concern Designer is now displayed, as apparent in Figure 8.13.
Figure 8.13 The Concern Designer opened to actualize a new database query
From the Add Table dialog, add the tblInventory table and then bang on the Close on to aish the dialog.
We charge to change the concern blazon from a Baddest to an Update query. We do so by selecting the Change Blazon card account from the capital Concern menu, or by beat on the Change Blazon on on the Concern toolbar, and then selecting the Amend card item.
In the Diagram area of the Concern Designer, bang on the checkbox for the WholesalePrice field, as that is the acreage we’re activity to update.
In the Grid pane, access the afterward blueprint in the New Value cavalcade in the row for the WholesalePrice acreage that we aloof added:
This blueprint accepts a constant value, which is the percentage that the broad amount should be added by. Back the concern is executed, the catechism mark in the blueprint will be replaced by the constant amount that is provided. The Concern Designer should attending like that apparent in Figure 8.14.
Figure 8.14 The concern to amend the WholesalePrice acreage in the tblInventory table
Although we could now run and analysis our concern aural the Concern Designer, we will (soon) do it from the Solution Explorer.
Close the Concern Designer and bang on the Yes on when prompted to save the changes to the UpdateWholesale.dtq query.
Double-click on tblInventory in the Server Explorer to display all the accepted abstracts in that table. These are the ethics afore we run the query calligraphy to amend the broad price.
You may appetite to booty a snapshot of the abstracts so that you can calmly verify the new prices afterwards active the amend query. You can do so by selecting all the rows that are actuality displayed and afresh artful and pasting them in a Notepad book (or any added apparatus of your liking).
Similar to what we showed ahead with a script, we can run a concern by boring and bottomward it assimilate a database reference. We can additionally run it on the absence advertence by right-clicking on the concern that we appetite to run and selecting the Accessible card item.
The ambience card displayed back you right-click on a concern additionally contains Architecture and Architecture On card items that accessible the Concern Designer adjoin the default or a defined database reference.
Drag and bead the UpdateWholesale concern assimilate the advertence for the Novelty database in the Solution Explorer.
The Execute Scripts or Queries chat box is shown, giving us a adventitious to affirm that we appetite to run the calligraphy on the defined database. Bang on the Yes on to abide and to run the query.
The Define Concern Parameters chat box is apparent because our concern contains a parameter. Access a valuesay, 10as the percentage access for the broad prices. Bang on the OK on to continue.
A bulletin box is displayed, advertence the cardinal of rows afflicted by the query. Bang on OK to aish it.
Repeat footfall 9 to afresh affectation the abstracts in the tblInventory table. The table should accommodate the adapted broad prices, as apparent in Figure 8.15.
Figure 8.15 The abstracts in the tblInventory table, afterwards accretion the WholesalePrice acreage by 10 percent
| Visual Studio Create Database Diagram – visual studio create database diagram
| Allowed to help my personal website, on this time I’m going to demonstrate about visual studio create database diagram