I have a windows form app with a DataGridView
populated by a TableAdapter
. I'm using the Fill
method to update the data for the UI in a looping Async
sub like so.
Private Async Sub updateUI()
Dim sw As New Stopwatch
While True
Await Task.Delay(3000)
sw.Restart()
myTableAdapter.Fill(getDataWithMySQL())
'myTableAdapter.Fill(myDataSet.myTable)
logger.Debug(sw.ElapsedMilliseconds)
End While
End Sub
The getDataWithMySQL
function is as follows:
Private Function getDataWithMySQL() As myDataSet.myDataTable
Dim connStr As String = My.Settings.myConnectionString
Dim sql As String = "SELECT ... LEFT JOIN ..."
Dim dt As New myDataSet.myDataTable
Using conn As New MySqlConnection(connStr)
Using cmd As New MySqlCommand()
With cmd
.CommandText = sql
.Connection = conn
End With
Try
conn.Open()
Dim sqladapter As New MySqlDataAdapter(cmd)
sqladapter.Fill(dt)
Catch ex As MySqlException
MsgBox(ex.Message)
End Try
End Using
End Using
Return dt
End Function
myTableAdapter.Fill(myDataSet.myTable)
works fine but performs poorly whereas myTableAdapter.Fill(getDataWithMySQL())
performs better as reported in my as yet unanswered question here.
For some reason, myTableAdapter.Fill(getDataWithMySQL())
does not work any more. It doesn't throw an error and dt
is populated with the correct data but the DataGridView
is not updating. It has worked previously and I don't think I've changed anything that would affect this. Any ideas why the DataGridView
is not updating?