I have an application where I'm loading several combo boxes from calls to stored procedures on the load of the form. The code is simple, but I have a question on how to clear the data table variable I'm using. As you can see from the code below I used two separate data table variables dt and dt1, which works fine. If I just used the single variable dt for each of the combo boxes what I would see is blank items in the second combo box loaded, which I assume came from the first use of the data table. I then thought I could clear the dt using the dt.clear method and it(dt) would be reloaded with the second combo box fill method (da.Fill(dt)). However when I tried this the second combo box was blank. As I said, my solution works (using two variables), but I'd like to know why the clear method causes a problem since its' followed by the second fill and is there a better way to handle this situation.
Thanks,
Tom
Me.cboStation.DisplayMember = "StationDesc"
Me.cboStation.ValueMember = "sID"
da = clsDept.GetStations
da.Fill(dt)
Me.cboStation.DataSource = dt
' I had the code dt.clear here, but it doesn't work
Me.cboStatus.DisplayMember = "Status"
Me.cboStatus.ValueMember = "sID"
da = clsDept.GetMemberStatus
da.Fill(dt1)
Me.cboStatus.DataSource = dt1
Thanks,
Tom
Me.cboStation.DisplayMember = "StationDesc"
Me.cboStation.ValueMember = "sID"
da = clsDept.GetStations
da.Fill(dt)
Me.cboStation.DataSource = dt
' I had the code dt.clear here, but it doesn't work
Me.cboStatus.DisplayMember = "Status"
Me.cboStatus.ValueMember = "sID"
da = clsDept.GetMemberStatus
da.Fill(dt1)
Me.cboStatus.DataSource = dt1