AddThis Social Bookmark Button


Developing Pocket PC Apps with SQL Server CE
Pages: 1, 2, 3, 4, 5, 6

Figure 4: Relationship between the Stores and Orders tables

The next step is to load the bookstores list into the ComboBox control using the SqlCeDataReader class.

Sub LoadStores()
  Dim reader As SqlCeDataReader
  Dim cmd As New SqlCeCommand( _
    "SELECT * FROM Stores", conn)
  reader = cmd.ExecuteReader
  While reader.Read
      cboStoreID.Items.Add( _
  End While
End Sub

So, when the Form is loaded, the ComboBox is filled with the bookstore list:

Figure 5: Populating the ComboBox

When a Store ID is selected, it will display the name of the store selected:

Private Sub cboStoreID_SelectedIndexChanged( _
  ByVal sender As System.Object, _
  ByVal e As System.EventArgs) _
  Handles cboStoreID.SelectedIndexChanged
    Dim sql As String = _
      "SELECT * FROM Stores WHERE storeID=" & _
    Dim cmd As New SqlCeCommand(sql, conn)
    Dim reader As SqlCeDataReader = cmd.ExecuteReader
    lblStoreName.Text = reader.Item("storeName")
End Sub

Consuming the Web Service

To search for specific titles, our application will use the Web service. Consuming a Web service in .NET CF is no different from consuming it on the .NET Framework (select the project in the Solution Explorer, right click on it, choose Add Web Reference, and supply the path to the service's WSDL). The only issue to note here is to ensure that actual machine name of the Web service is used. Using localhost will not work in Beta 1 of the SDE.

In the file, the Web reference needs to be modified to work with your system: In the Solution Explorer, locate the TitlesWS Web reference, select it, and change the Web Reference property to the correct WSDL URL (it is currently http://YOURHOSTHERE/Services/service1.asmx).

For more information on creating .NET Web Services, check out the Web Services section of the .NET DevCenter.

The result of the Web service is bound to the Result ComboBox.

Private Sub cmdSearch_Click( _
  ByVal sender As System.Object, _
  ByVal e As System.EventArgs) _
  Handles cmdSearch.Click
    Dim ws As New TitlesWS.Service1()
    ' get the web service
    ds = ws.getTitles(txtSearch.Text)
    cboResult.DataSource = ds.Tables(0)
    cboResult.DisplayMember = "title"
End Sub

Pages: 1, 2, 3, 4, 5, 6

Next Pagearrow