GrahamI on Fri, 31 May 2013 06:40:33

I have a TextBox on a TabControl TabPage that is bound to a Column in an SQL Server 2008 Db Table.  I'm aware of the problems of Controls on a TabControl:-

' Controls contained in a TabPage are not created until the tab page is shown, 
' and any data bindings in these controls are not activated until the tab page is shown. 
    Dim intTab As Integer = 0
    For intTab = 0 To Me.tabClients.TabCount - 1

So I handle that issue with the above code in the Form_Shown event.
This gives me the desired result. The TextBox Controls load with their correct data from the Data Table.

However, when I change the Text in the TextBox and perform an Update as follows:-

' Update the Table with any Data changes.
    Me.Cursor = Cursors.WaitCursor
    Me.Cursor = Cursors.Default
    MsgBox("Update successful")
Catch ex As Exception
    MsgBox("Update failed - " & ex.Message)
End Try
Me.Cursor = Cursors.Default

The MessageBox indicates that the Update was successful but the data in the Table hasn't changed to the new data in the TextBox.

Does anyone have a suggestion on a possible cause for this behaviour?

I've tried all manner of tests and the only thing that stands out is that the above code will be successful with data in a TextBox that has a parent of a Form or a GroupBox on a Form. But fails miserably when a Tab Control is involved??


VB Developer



Cor Ligthert on Fri, 31 May 2013 06:51:49

Why not force in that procedure a hard coded update like

TheDataTable.WhateverField(0) = "x" and try it again.

Just to see what the error is of course.


GrahamI on Fri, 31 May 2013 07:17:07

Hi Cor,

Thank you.  Could you give me the Exact Syntaxt for that please?

TheDataTable = 'Clients'

WhateverField(0) = 'eMailAddress'

How does that fit into the reference to the TableAdapter?

Regards, Graham

Cor Ligthert on Fri, 31 May 2013 12:42:57

That I tried to tell, that is impossible to give for me.

You use a generated strongly typed dataset. 

So probably that is something like.

Me.MyDataSet.Clients.Clientrow(0).AField(0) = "Does not matter if it is a string"

GrahamI on Sat, 01 Jun 2013 03:05:17

Hi Cor,

More testing in the Immediate window shows an interesting result.

If I put a Break in the code before


and test the following in the Immediate window


I will get the String from the TextBox that that I have just changed that is bound to Field 13 (eMailAddress) in the Clients Table.

In short, the DataSet is changing as the TextBoxes change, but the TableAdapter seems not to be getting that change.

If I test again after


I will get the same result, the new text that I have just changed the TextBox to.

So the DataSet is correct.  The TableAdapter seems to be the issue here.

Is there any way you know of that can force the TableAdapter to Refresh?

EdwardNewgate on Mon, 03 Jun 2013 06:09:29

To refresh the dataadapter, I think you may need to re-connect to database and then read data from db. 

GrahamI on Mon, 03 Jun 2013 08:57:54

Hi Edward,

It's not a DataAdapter that I have an Issue with, it's a TableAdapter.

I have refreshed that.

Youen Zen on Fri, 07 Jun 2013 09:43:20

As far as I see, there isn't anything special of datasource between tab control and other controls. For your description, I suggest take following steps to detect problem:

1. Check this row's state before and after TableAdapter.Update method, to see if its status changed, this state before update should be modified, then changed to unchange after updating. DataRowState Enumeration.

2. Please check UpdateCommand in TableAdapter, maybe this command was successfully executed but this command has problem. You could try to data wizard to re-create this adapter.

Hope this helps.


GrahamI on Fri, 07 Jun 2013 21:45:59

Thanks for your input.  I eventually resolved the problem as a corrupted TableAdapter by deleting the BindingSource and the TableAdapter and then re-creating the Bindings.

I have no idea why or how the TableAdapter became corrupted.  However, the BindingSource wasn't and the TableAdapter wasn't Adapting so I decided to delete both and start again, re-binding the 30 or 40 Controls involved.