I have a textbox bound to a dataset field, should this text box automatically update with the data in that field? Yes/No?
The book im working from basically has a drop down box that I select a country from, this then fills the dataset with customers from that country, and in the book the application then shows the first customers name from that country in the textbox(based on the book having the textbox bound to dataset->customer field, will auto update the textbox.text value with the data from the dataset)
However when i recreate the example from the book the textbox field just stays empty upon selecting a country from the dropdown box.
I know the dataset is ok as i can manually say textbox1.text = ds.etc etc
Any advice would be much apprciate.
my code for the drop down box change is as follows
Private Sub cboCountry_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCountry.SelectedIndexChanged
DsCustomers1.Clear()
Dim con As New Component1
con.DsCustomers1 = con.FillCustomers(cboCountry.Text)
positionindicator()
MsgBox(con.DsCustomers1.Tables.Item("customers").Rows(1).Item(1).ToString) 'just a line te test dscustomers1 is filling
End Sub
code for fillcustomers as follows
Public Function FillCustomers(ByVal country As String) As LearningVBdata.dsCustomers
Dim ds As New LearningVBdata.dsCustomers
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter2.SelectCommand.Parameters.Item(0).Value = country
Me.OleDbDataAdapter2.Fill(ds)
Me.OleDbConnection1.Close()
Return ds
End Function
The book im working from basically has a drop down box that I select a country from, this then fills the dataset with customers from that country, and in the book the application then shows the first customers name from that country in the textbox(based on the book having the textbox bound to dataset->customer field, will auto update the textbox.text value with the data from the dataset)
However when i recreate the example from the book the textbox field just stays empty upon selecting a country from the dropdown box.
I know the dataset is ok as i can manually say textbox1.text = ds.etc etc
Any advice would be much apprciate.
my code for the drop down box change is as follows
Private Sub cboCountry_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCountry.SelectedIndexChanged
DsCustomers1.Clear()
Dim con As New Component1
con.DsCustomers1 = con.FillCustomers(cboCountry.Text)
positionindicator()
MsgBox(con.DsCustomers1.Tables.Item("customers").Rows(1).Item(1).ToString) 'just a line te test dscustomers1 is filling
End Sub
code for fillcustomers as follows
Public Function FillCustomers(ByVal country As String) As LearningVBdata.dsCustomers
Dim ds As New LearningVBdata.dsCustomers
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter2.SelectCommand.Parameters.Item(0).Value = country
Me.OleDbDataAdapter2.Fill(ds)
Me.OleDbConnection1.Close()
Return ds
End Function