Tuesday 11 March 2014

Fill ComboBox using Sub Query(Two Table Based On Condition)

  Private Sub showstate()
        Dim dt As DataTable = objdb.getdata("select distinct college_new_state_code from AffidavitData where college_new_state_code is not null and college_name_removesc is not null order by college_new_state_code asc ", objdb.localconnection)
        If dt.Rows.Count > 0 Then
            For i As Integer = 0 To dt.Rows.Count - 1
                Dim dt1 As DataTable = objdb.getdata("select distinct state from state_master  where state_code='" & dt.Rows(i).Item("college_new_state_code") & "' and state is not null", objdb.localconnection)
                If IsDBNull(dt1.Rows(0).Item("state")) = False Then
                    cmbstate.Items.Add(dt1.Rows(0).Item("state"))
                Else
                    i = i - 1
                End If
            Next
        End If

No comments:

Post a Comment

Followers