I am working on a windows form to allow my users to search for a specific equipment number and display it's current information. If the information was entered incorrectly, the user will be allowed to update certain information.
The current information is displayed in read-only text boxes.
The information that will be able to be updated is in contained in combo boxes.
What I want to do is have the current value displayed in the combo box.
This is the code I have so far.
Code:
Private Sub LoadLocationLookup()
'using runtime DataSet and DataAdapters to load combo boxes
Me.Cursor = Cursors.WaitCursor
Dim strSQL As String
If cmbFile.SelectedText = "APC" Then
strSQL = _
"SELECT LocationID, LocationName from APC_Location " + _
"ORDER BY LocationName;"
Else
strSQL = _
"SELECT LocationID, LocationName from RMA_Location " + _
"ORDER BY LocationName;"
End If
' connect to SQL Server
Dim strConn As New SqlConnection(APC_WirelessConnectionString)
strConn.Open()
Dim daLocation As New SqlDataAdapter
Dim cmdLocation As New SqlCommand(strSQL, strConn)
Dim dsLocation As New DataSet
Dim dvLocation As New DataView
cmdLocation.CommandType = CommandType.Text
daLocation.SelectCommand = cmdLocation
'Try Catch Block for error checking
Try
daLocation.Fill(dsLocation)
dvLocation = dsLocation.Tables(0).DefaultView
With Me.cmbLocation
.DataSource = dvLocation
.DisplayMember = "LocationName"
.ValueMember = "LocationID"
End With
Catch ex As Exception
MessageBox.Show(ex.Message.ToString)
End Try
strConn.Close()
Me.Cursor = Cursors.Default
End Sub
I've found the FindString and FindStringExact properties, but I'm not sure how to use them to do what I want.
Thanks for any help you can give me.
Karen