Dataset being modified??

Hi Everyone,

I am new to VB.NET/ADO.NET programming. I have run into a problem. I was trying to develop a windows form containing a combo box and a text box. Now this form will connect to a MS Access database and it will be populating a OleDbDataset object with the result of a SQL Select query (the select query will select all the Client ID's and the Client names from our Client Table). I have bound the combo box to the client ID's and so when the form loads, the combo box contains all the ID's read in from the table. I have also bound the text box to the client names. So when I change the value in the combo box, the corresponding client name is displayed in the text box. I want the text box to be updated as soon as the value in the combo box is changed (either by selecting a new value from the drop down list or by typing in a new value and hitting enter).

Now I have 2 questions.

One, when I select a new value either through the drop down list of the combo box or by scrolling with my mouse wheel, the text box is updated correctly with the right information. But when I type in a new value manually and hit enter, then the text box is not updated. It still shows the old client name. Which event do I need to handle to get this functionality as well  I want the user to be able to enter a client ID manually as well as be able to scroll. I know I have to handle a event to get that going, but I just could not figure out which one. I tried a couple of them like SelectedIndexChanged, SelectedValueChanged, ValueMemberChanged, DisplayMemberChanged and so on, but no effect.

Second, I tried the following code with one of the event handlers:
  
Private Sub ComboBox1_Changed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged      
        Dim cmbId As String, crrClient As String, myDataRow() As DataRow
        cmbId = ComboBox1.Text
        myDataRow = DsSampleLogin1.Tables("Sample_Login").Select("Lab_No= " & cmbId)
        crrClient = myDataRow(0).Item("Client")
        TextBox1.Text = crrClient
End Sub

Does the above 'myDataRow' statement in anyway modify the Dataset 'DsSampleLogin1'  I am having some trouble with lost client names. I can elaborate on that if you think the question is not clear.

Any help in this regard will be greatly appreciated. I am stuck at this point and need some help before I can move on.

Thanks a lot in advance.
Shahnaz.


Answer this question

Dataset being modified??

  • Itay Sagui

    have you tried the .textchanged event
  • Dataset being modified??