The horrible part is ... I had this working!
Then I found a problem with the underlying table, fixed it, and it hasn't worked correctly since ...
What I want to do:
W/in a data grid view, build a list of carriers and show the available networks as a combo box.
If the carrier already exists, its' current network should show as the current value in the combo box.
What I have right now:
The list of carriers and a blank in the combo box.
The combo box is filled with the available networks.
If I select a network, as soon as I go to the next row in the view, the box is blank again.
This is the code I'm currently using:
Code:
Private Sub frmCarrier_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
LoadNetworkLookup()
Me.taCarrier.Fill(Me.dsAPC_Wireless.Carrier)
End Sub
Private Sub LoadNetworkLookup()
'using runtime DataSet and DataAdapters to load combo box
Me.Cursor = Cursors.WaitCursor
'Networks
Dim strSQL As String = _
"SELECT NetworkID, NetworkTypeName from Network;"
' connect to SQL Server
Dim strConn As New SqlConnection(APC_WirelessConnectionString)
strConn.Open()
Dim daNetwork As New SqlDataAdapter
Dim cmdNetwork As New SqlCommand(strSQL, strConn)
Dim dsNetwork As New DataSet
Dim dvNetwork As New DataView
cmdNetwork.CommandType = CommandType.Text
daNetwork.SelectCommand = cmdNetwork
'Try Catch Block for error checking
Try
daNetwork.Fill(dsNetwork)
dvNetwork = dsNetwork.Tables(0).DefaultView
With Me.dgv_cmbNetwork
.DataSource = dvNetwork
.DisplayMember = "NetworkTypeName"
.ValueMember = "NetworkID"
End With
Catch ex As Exception
MessageBox.Show(ex.Message.ToString)
End Try
strConn.Close()
Me.Cursor = Cursors.Default
End Sub
Does any one have a clue what I broke? And better yet, how I can fix it?
Thanks,
Karen