Table Adapter Refresh too slow?

  • Thread starter Thread starter Vayse
  • Start date Start date
V

Vayse

I have a datagrid bound to a table adapter. That is, gridTempSchedule is
bound to TempScheduleTableAdapter
Heres my code

If bfunCreateSchedule() Then
Me.TempScheduleTableAdapter.Fill(Me.AssetsDataSet.TempSchedule)

In bfunCreateSchedule() I delete the data from TempSchedule, and create a
new schedule.
If I run the code, gridTempSchedule just goes empty. If I step through the
Me.TempScheduleTableAdapter.Fill, the grid dsiplays correctly.
So it seems that TempScheduleTableAdapter is loading the deleted table, but
if I step through it gets enough time to load the correct data.

Any suggestions on how I would get around this?
Thanks
Vayse
 
Hi,

First, your grid is bound to a DataTable (or better to its DefaultView
DataView).
You mention that you delete the data. Do you delete the table?
 
I created the grid using the Data Sources windows, that is I dragged the
TempSources table onto the form.
So its datasource is TempScheduleBindingSource, as created by the wizard.

I don't delete the table. I'm using ADODB, along these lines

stSQL = "DELETE * FROM TempSchedule"
cnnAsset.Execute(stSQL, lRecords)

stSQL = "TempSchedule"
rsSchedule = New ADODB.Recordset
rsSchedule.Open(stSQL, cnnAsset, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic)
With rsSchedule
.AddNew()

Miha Markic said:
Hi,

First, your grid is bound to a DataTable (or better to its DefaultView
DataView).
You mention that you delete the data. Do you delete the table?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Vayse said:
I have a datagrid bound to a table adapter. That is, gridTempSchedule is
bound to TempScheduleTableAdapter
Heres my code

If bfunCreateSchedule() Then
Me.TempScheduleTableAdapter.Fill(Me.AssetsDataSet.TempSchedule)

In bfunCreateSchedule() I delete the data from TempSchedule, and create a
new schedule.
If I run the code, gridTempSchedule just goes empty. If I step through
the Me.TempScheduleTableAdapter.Fill, the grid dsiplays correctly.
So it seems that TempScheduleTableAdapter is loading the deleted table,
but if I step through it gets enough time to load the correct data.

Any suggestions on how I would get around this?
Thanks
Vayse
 
Vayse,

Where is you TableAdapter in this code?

Cor

Vayse said:
I created the grid using the Data Sources windows, that is I dragged the
TempSources table onto the form.
So its datasource is TempScheduleBindingSource, as created by the wizard.

I don't delete the table. I'm using ADODB, along these lines

stSQL = "DELETE * FROM TempSchedule"
cnnAsset.Execute(stSQL, lRecords)

stSQL = "TempSchedule"
rsSchedule = New ADODB.Recordset
rsSchedule.Open(stSQL, cnnAsset, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic)
With rsSchedule
.AddNew()

Miha Markic said:
Hi,

First, your grid is bound to a DataTable (or better to its DefaultView
DataView).
You mention that you delete the data. Do you delete the table?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Vayse said:
I have a datagrid bound to a table adapter. That is, gridTempSchedule is
bound to TempScheduleTableAdapter
Heres my code

If bfunCreateSchedule() Then
Me.TempScheduleTableAdapter.Fill(Me.AssetsDataSet.TempSchedule)

In bfunCreateSchedule() I delete the data from TempSchedule, and create
a new schedule.
If I run the code, gridTempSchedule just goes empty. If I step through
the Me.TempScheduleTableAdapter.Fill, the grid dsiplays correctly.
So it seems that TempScheduleTableAdapter is loading the deleted table,
but if I step through it gets enough time to load the correct data.

Any suggestions on how I would get around this?
Thanks
Vayse
 
It was in the first post. I use ADO to manipulate the table, then
Me.TempScheduleTableAdapter.Fill(Me.AssetsDataSet.TempSchedule)



Cor Ligthert said:
Vayse,

Where is you TableAdapter in this code?

Cor

Vayse said:
I created the grid using the Data Sources windows, that is I dragged the
TempSources table onto the form.
So its datasource is TempScheduleBindingSource, as created by the wizard.

I don't delete the table. I'm using ADODB, along these lines

stSQL = "DELETE * FROM TempSchedule"
cnnAsset.Execute(stSQL, lRecords)

stSQL = "TempSchedule"
rsSchedule = New ADODB.Recordset
rsSchedule.Open(stSQL, cnnAsset, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic)
With rsSchedule
.AddNew()

Miha Markic said:
Hi,

First, your grid is bound to a DataTable (or better to its DefaultView
DataView).
You mention that you delete the data. Do you delete the table?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

I have a datagrid bound to a table adapter. That is, gridTempSchedule is
bound to TempScheduleTableAdapter
Heres my code

If bfunCreateSchedule() Then
Me.TempScheduleTableAdapter.Fill(Me.AssetsDataSet.TempSchedule)

In bfunCreateSchedule() I delete the data from TempSchedule, and create
a new schedule.
If I run the code, gridTempSchedule just goes empty. If I step through
the Me.TempScheduleTableAdapter.Fill, the grid dsiplays correctly.
So it seems that TempScheduleTableAdapter is loading the deleted table,
but if I step through it gets enough time to load the correct data.

Any suggestions on how I would get around this?
Thanks
Vayse
 
it turns out that not closing the ADODB connection was problem.

In bfunCreateSchedule I had code as below, but had forgot to add
cnnAsset.Close.
Once this was added, the grid refreshed fine.

Thanks
Vayse

Private Function bfunCreateSchedule as Boolean
Dim cnnAsset As New ADODB.Connection ' Connection to the database
Dim rsSchedule As ADODB.Recordset

stSQL = "DELETE * FROM TempSchedule"
cnnAsset.Execute(stSQL, lRecords)

stSQL = "TempSchedule"
rsSchedule = New ADODB.Recordset
rsSchedule.Open(stSQL, cnnAsset, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic)

With rsSchedule
etc...
 
Back
Top