0
votes

Im making a silverlight 5 application and im using RIA WCS services to connect to sql, i can add data,delete data, edit data, and get all data, but the problem is that i need to retrieve a specific record not the whole entity, when i try the following code just nothing happens:

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click ' InitializeComponent() objctx = New BanksDomainContext Dim itemType = Branch_NameComboBox.SelectedItem.GetType Dim pi = itemType.GetProperty(Branch_NameComboBox.DisplayMemberPath) Dim cbi = pi.GetValue(Branch_NameComboBox.SelectedItem, Nothing).ToString() Dim BranchName As String = cbi

    '   Dim query As EntityQuery(Of Branches) = objctx.GetBranchesDetailsQuery(BranchName)

    '  Dim loadOp As LoadOperation(Of Branches) = Me.objctx.Load(query)
    '  DataGrid1.ItemsSource = loadOp.Entities
    '  objctx.Load(query, LoadData, Nothing)

    Dim loadOp = Me.objctx.Load(Me.objctx.GetBranchesDetailsQuery(BranchName))


    LoadData(loadOp)


End Sub
Private Sub LoadData(lo As LoadOperation)

    For Each br As Branches In lo.Entities

        AddressTextBlock.Text = br.Address
        CoordinatesTextBlock.Text = br.Coordinates
        ManagerTextBlock.Text = br.Manager
        PhoneTextBlock.Text = br.Phone
        FaxTextBlock.Text = br.Fax        
Next

End Sub

can someone guide me on how to do it?

1

1 Answers

0
votes

The following is the solution to load text boxes from SQL records by selecting the search term from a list box:

Private Sub Branch_NameComboBox_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles Branch_NameComboBox.SelectionChanged
    m_PushpinLayer.Children.Clear()
    objctx = New BanksDomain
    Dim itemType = Branch_NameComboBox.SelectedItem.[GetType]()
    Dim pi = itemType.GetProperty(Branch_NameComboBox.DisplayMemberPath)
    Dim cbi = pi.GetValue(Branch_NameComboBox.SelectedItem, Nothing).ToString()
    Dim BranchName As String = cbi
    Dim itemType2 = NameComboBox.SelectedItem.[GetType]()
    Dim pi2 = itemType2.GetProperty(NameComboBox.DisplayMemberPath)
    Dim cbi2 = pi2.GetValue(NameComboBox.SelectedItem, Nothing).ToString()
    Dim BankName As String = cbi2
    Dim bb As EntityQuery(Of Branches) = From b In objctx.GetBranchesDetailsQuery(BranchName) Where b.Bank = BankName Select b



    Dim res As LoadOperation(Of Branches) = objctx.Load(bb, New Action(Of LoadOperation(Of Branches))(AddressOf GetBeansCompleted), True)

End Sub
Private Sub GetBeansCompleted(args As LoadOperation(Of Branches))


    For Each bc As Branches In args.Entities
        ' 
        Dim Latitude As Double = bc.Lat
        Dim Longitude As Double = bc.Lon

        Dim CoO As Location = New Location

        CoO.Latitude = Decimal.Parse(Latitude)
        CoO.Longitude = Decimal.Parse(Longitude)

        Dim BName As String = bc.Branch_Name.ToString
        Dim MKColor As Color = GetThisColor(bc.MapKeyColor.ToString)




        AddPushPin(BName, CoO, MKColor)

        AddressTextBlock.Text = (bc.Address.ToString)
        LatTextBlock.Text = (Decimal.Parse(Latitude))
        LonTextBlock.Text = (Convert.ToDecimal(Longitude))
        ManagerTextBlock.Text = (bc.Manager.ToString)
        PhoneTextBlock.Text = (bc.Phone.ToString)
        FaxTextBlock.Text = (bc.Fax.ToString)



    Next


End Sub