Imports System.Data.OleDb Imports System.Web.Services _ Public Class Ch11WS_ProductsDS Inherits System.Web.Services.WebService #Region " Web Services Designer Generated Code " Public Sub New() MyBase.New() 'This call is required by the Web Services Designer. InitializeComponent() 'Add your own initialization code after the InitializeComponent() call End Sub 'Required by the Web Services Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Web Services Designer 'It can be modified using the Web Services Designer. 'Do not modify it using the code editor. Private Sub InitializeComponent() components = New System.ComponentModel.Container End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 'CODEGEN: This procedure is required by the Web Services Designer 'Do not modify it using the code editor. If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub #End Region Dim CS As String = _ "Data Source=" & _ "C:\Inetpub\wwwroot\Chapter11WebService\data\TaraStore.mdb;" & _ "Provider=Microsoft.Jet.OLEDB.4.0" Dim OleDbConnection1 As New OleDbConnection(CS) ' Insert the WS_GetCat() WebMethod here ' The WS_GetSubCats() WebMethod _ Public Function WS_GetSubCats(ByVal CatID As Integer) As DataSet Dim MySQL As String = "SELECT * FROM SubCategories WHERE CategoryID = " & CatID Dim objCM2 As New OleDbDataAdapter(MySQL, OleDbConnection1) Dim objDS2 As New DataSet objCM2.Fill(objDS2, "SubCategories") Return objDS2 End Function ' The WS_GetProducts() WebMethod _ Public Function WS_GetProducts(ByVal SubCatID As Integer) As DataSet Dim MySQL As String = "SELECT * FROM Products WHERE SubCategoryID = " & SubCatID Dim objCM3 As New OleDbDataAdapter(MySQL, OleDbConnection1) Dim objDS3 As New DataSet objCM3.Fill(objDS3, "Products") Return objDS3 End Function ' The WS_GetProduct() WebMethod _ Public Function WS_GetProduct(ByVal ProdID As Integer) As DataSet Dim MySQL As String = "SELECT * FROM Products WHERE ProductID = " & ProdID Dim objCM4 As New OleDbDataAdapter(MySQL, OleDbConnection1) Dim objDS4 As New DataSet objCM4.Fill(objDS4, "Products") Return objDS4 End Function End Class