dejota6
Newcomer
I have a fairly simple question I am sure
I have a datagrid on my form. here is my code
My question is this, I run this sub every 30 seconds to refresh the data being displayed in the datagrid. what do i need to add to make sure that the datagrid's data is cleared and the repopulated with the new data from the database?
I have a datagrid on my form. here is my code
Visual Basic:
Protected ETSDataSet As New DataSet()
Protected ETSDataView As DataView
Protected Const SQL_CONNECTION_STRING As String = "Server=tcwsql5;DataBase=etsbesql;Integrated Security=SSPI"
Visual Basic:
Private Sub LoadData()
Dim strConnection As String = SQL_CONNECTION_STRING
Dim IsConnecting As Boolean = True
While IsConnecting
Try
Dim ETSConnection As New SqlConnection(strConnection)
Dim sqlAdapter As New SqlDataAdapter("SELECT Employee, Status, TimeOut, ExpectedReturn, Comments " & _
"FROM tblNameList", ETSConnection)
sqlAdapter.Fill(ETSDataSet, "Names")
ETSDataView = New DataView(ETSDataSet.Tables(0), "", "Employee ASC", DataViewRowState.OriginalRows)
ETSDataView.AllowNew = False
IsConnecting = False
Catch exc As Exception
MsgBox("Could not connect")
End
End Try
End While
dgUsers.DataSource = ETSDataView
Dim RowCount As Integer = ETSDataView.Count()
If RowCount < 35 Then
dgUsers.Height = (RowCount - 2) * 20
Else
dgUsers.Height = 700
End If
Me.Height = dgUsers.Height + 10
End Sub
My question is this, I run this sub every 30 seconds to refresh the data being displayed in the datagrid. what do i need to add to make sure that the datagrid's data is cleared and the repopulated with the new data from the database?