Because Their Schemas Are D
Posted: Sun Jan 05, 2025 4:49 am
A statement that returns rows of data The next step is to define the SQL query statement used to access the data. Since we only want to return those products that belong to a specific category I reuse the statement GetProductsfrom above SELECT but add a WHEREclause WHERE CategoryID CategoryID. The parameter in it CategoryIDindicates to the TableAdapter Configuration Wizard that the method. We are generating will require an input parameter of the corresponding class that is a nullnullable integer. . Figure 16 Enter a query to return only products in a specific category In the last step we can.
Choose which data access mode to use and customize the name of the generated method. For the Fill belgium phone number data lets change the name to FillByCategoryID for the method that returns the DataTable mode GetX lets use GetProductsByCategoryIDthis name. . Figure 17 Choosing Names for TableAdapter Methods After completing the wizard the DataSet Designer includes these new TableAdapter methods. . Figure 18 Searching for. Products by category Take a moment to add a method using the same technique .GetProductByProductIDproductID These parameterized queries can be tested directly in the DataSet Designer. Rightclick on the method in the TableAdapter and select Preview Data..
Next enter the values for the corresponding parameters and click Preview. . Figure 19 List of products that belong to the Beverages category With the methods in our DAL we can design an ASP.NET web page to display the products that belong to a specified category. The following example displays all products that belong to the Beverages category 1.GetProductsByCategoryIDcategoryIDCategoryID Beverages codeWindow . ASP.NET 1 6 7 10 11 12 13 14 21 22 23 24 Beverages Beverages codeWindow C 1 using System 2 using System.Data 3 using System.Configuration 4 using System.Collections 5 using System.Web 6 using System .Web.Security 7 using.
Choose which data access mode to use and customize the name of the generated method. For the Fill belgium phone number data lets change the name to FillByCategoryID for the method that returns the DataTable mode GetX lets use GetProductsByCategoryIDthis name. . Figure 17 Choosing Names for TableAdapter Methods After completing the wizard the DataSet Designer includes these new TableAdapter methods. . Figure 18 Searching for. Products by category Take a moment to add a method using the same technique .GetProductByProductIDproductID These parameterized queries can be tested directly in the DataSet Designer. Rightclick on the method in the TableAdapter and select Preview Data..
Next enter the values for the corresponding parameters and click Preview. . Figure 19 List of products that belong to the Beverages category With the methods in our DAL we can design an ASP.NET web page to display the products that belong to a specified category. The following example displays all products that belong to the Beverages category 1.GetProductsByCategoryIDcategoryIDCategoryID Beverages codeWindow . ASP.NET 1 6 7 10 11 12 13 14 21 22 23 24 Beverages Beverages codeWindow C 1 using System 2 using System.Data 3 using System.Configuration 4 using System.Collections 5 using System.Web 6 using System .Web.Security 7 using.