Hello All:
I have a test app I am building which I call "IP Manager". This app is a Windows App from VB.Net which does a WMI query, and populates a dataset which I create at run time from a (relational tables) schema I built.
The schema gets populated OK.
Here is a picture of the dataset ("tblAdapters"):
There is a one-to-many relationship for all the relations (possibly, but not always). I force the DNSAddr subtable to have 3 rows, even if all the IPAddresses are "" (some adapters found in the query are not configured).
I am Displaying the Configurations.Description field in a combobox ("cboAdapters"). All the other data fields are in textboxes. A pertinate textbox to this problem is txtIPAddr, which should display the IPAddress field from the first row of the child table in the ConfigsIPAddress relation. I have other textboxes which should display a row from one of the child tables.
In the form_load subroutine there is this, which databinds the controls:
When the form loads, the combobox and all the textboxes are filled with correct data from the dataset.
However, when the combobox selection is changed, all the textboxes which have bindings that do not reference a relation change correctly. The ones which use the format "tblAdapters.Relations("RelationName").ChildTable.Rows(x)" do not.
I am just starting to learn VB.net (although I have lots of VB & VBA experience)
How can I fix this?
Thanks
Rob
I have a test app I am building which I call "IP Manager". This app is a Windows App from VB.Net which does a WMI query, and populates a dataset which I create at run time from a (relational tables) schema I built.
The schema gets populated OK.
Here is a picture of the dataset ("tblAdapters"):
VB.NET:
[FONT=Courier New][SIZE=3]
[FONT=Courier] Table: DNSAddr[/FONT]
[FONT=Courier] Relation [U]Fields[/U][/FONT]
[FONT=Courier] |----- ConfigsDNSAddress -- AdapterDesc[/FONT]
[FONT=Courier] | Index[/FONT]
[FONT=Courier] | IPAddress[/FONT]
[FONT=Courier] |[/FONT]
[FONT=Courier] |[/FONT]
[FONT=Courier]Table: Configurations | Table: IPAddr[/FONT]
[FONT=Courier]Fields: | Relation [U]Fields[/U][/FONT]
[FONT=Courier]MACAddress |----- ConfigsIPAddress --- AdapterDesc[/FONT]
[FONT=Courier]Index | Index[/FONT]
[FONT=Courier]Description ----------| IPAddress[/FONT]
[FONT=Courier]DNSDomain |[/FONT]
[FONT=Courier]DNSHostName |[/FONT]
[FONT=Courier]PrimaryWINS | Table: GatewayAddr[/FONT]
[FONT=Courier]SecondaryWINS | Relation [U]Fields[/U][/FONT]
[FONT=Courier]ConfigType |---ConfigsGatewayAddress-- AdapterDesc[/FONT]
[FONT=Courier] | Index[/FONT]
[FONT=Courier] | IPAddress[/FONT]
[FONT=Courier] |[/FONT]
[FONT=Courier] |[/FONT]
[FONT=Courier] | Table: SubNetAddr[/FONT]
[FONT=Courier] | Relation [U]Fields[/U][/FONT]
[FONT=Courier] |---ConfigsSubnetAddress—-- AdapterDesc[/FONT]
[FONT=Courier] Index[/FONT]
[FONT=Courier] IPAddress[/FONT][/SIZE][/FONT]
There is a one-to-many relationship for all the relations (possibly, but not always). I force the DNSAddr subtable to have 3 rows, even if all the IPAddresses are "" (some adapters found in the query are not configured).
I am Displaying the Configurations.Description field in a combobox ("cboAdapters"). All the other data fields are in textboxes. A pertinate textbox to this problem is txtIPAddr, which should display the IPAddress field from the first row of the child table in the ConfigsIPAddress relation. I have other textboxes which should display a row from one of the child tables.
In the form_load subroutine there is this, which databinds the controls:
VB.NET:
[SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].cboAdapter
.DataSource = tblAdapters.Configuration
.DisplayMember = "Description"[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me
[/COLOR][/SIZE][SIZE=2].txtMAC.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Configuration, "MACAddress"))
.txtDHCP.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Configuration, "ConfigType"))
.txtWINS1.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Configuration, "PrimaryWINS"))
.txtWINS2.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Configuration, "SecondaryWINS"))
.txtDNSDomain.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Configuration, "DNSDomain"))
.txtIPAddr.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Relations("ConfigsIPAddress").ChildTable.Rows(0), "IPAddress"))
.txtSubnet.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Relations("ConfigsSubnetAddress").ChildTable.Rows(0), "IPAddress"))
.txtDefGW.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Relations("ConfigsGatewayAddress").ChildTable.Rows(0), "IPAddress"))
.txtDNS1.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Relations("ConfigsDNSAddress").ChildTable.Rows(0), "IPAddress"))
.txtDNS2.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Relations("ConfigsDNSAddress").ChildTable.Rows(1), "IPAddress"))
.txtDNS3.DataBindings.Add([/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Binding("Text", tblAdapters.Relations("ConfigsDNSAddress").ChildTable.Rows(2), "IPAddress"))
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With
[/COLOR][/SIZE]
When the form loads, the combobox and all the textboxes are filled with correct data from the dataset.
However, when the combobox selection is changed, all the textboxes which have bindings that do not reference a relation change correctly. The ones which use the format "tblAdapters.Relations("RelationName").ChildTable.Rows(x)" do not.
I am just starting to learn VB.net (although I have lots of VB & VBA experience)
How can I fix this?
Thanks
Rob