G
Guest
Hi all, i have a window application which make use of a timer class, whereby
every 5 seconds i have to refresh a datagrid,below is the codes
Public Sub TimerFired(ByVal sender As Object, _
ByVal e As System.Timers.ElapsedEventArgs)
'Label1.Text = "Server Time = " & e.SignalTime.ToString
tape()
end sub
Private Function tape()
Dim i As Integer
Dim ds3 As New DataSet
Dim ds4 As New DataSet
ds4 = a.RetrievePatient1()
Dim foodtable As DataTable
Dim idcolumn As DataColumn
Dim namecolumn As DataColumn
Dim foodemandcolumn As DataColumn
Dim row As DataRow
'make a table
foodtable = New DataTable("Food")
'make a column
idcolumn = New DataColumn("PatientID")
idcolumn.DefaultValue = "<PatientID>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(idcolumn)
namecolumn = New DataColumn("Name")
idcolumn.DefaultValue = "<Name>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(namecolumn)
foodemandcolumn = New DataColumn("DemandFood")
foodemandcolumn.DefaultValue = "<DemandFood>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(foodemandcolumn)
'a.RetrievePatient(patID)
'add row of data
For i = 0 To ds4.Tables(0).Rows.Count() - 1
'If TextBox1.Text = ds3.Tables(0).Rows(i)(0) Then
row = foodtable.NewRow
row("PatientID") = ds4.Tables(0).Rows(i)("PatientID")
row("Name") = ds4.Tables(0).Rows(i)("Name")
row("DemandFood") = ds4.Tables(0).Rows(i)("DemandFood")
foodtable.Rows.Add(row)
'DataGrid2.SetDataBindinga(ds2,"DemanfFood)
'End If
Next
ds4.Tables.Add(foodtable)
DataGrid2.SetDataBinding(ds4, "Food")
End Function
With the above coding data could not be retrieve to the datagrid
*datagrid couls br filled if the above codes are placed in a Form_Load or
button_Onclick
vitz...
every 5 seconds i have to refresh a datagrid,below is the codes
Public Sub TimerFired(ByVal sender As Object, _
ByVal e As System.Timers.ElapsedEventArgs)
'Label1.Text = "Server Time = " & e.SignalTime.ToString
tape()
end sub
Private Function tape()
Dim i As Integer
Dim ds3 As New DataSet
Dim ds4 As New DataSet
ds4 = a.RetrievePatient1()
Dim foodtable As DataTable
Dim idcolumn As DataColumn
Dim namecolumn As DataColumn
Dim foodemandcolumn As DataColumn
Dim row As DataRow
'make a table
foodtable = New DataTable("Food")
'make a column
idcolumn = New DataColumn("PatientID")
idcolumn.DefaultValue = "<PatientID>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(idcolumn)
namecolumn = New DataColumn("Name")
idcolumn.DefaultValue = "<Name>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(namecolumn)
foodemandcolumn = New DataColumn("DemandFood")
foodemandcolumn.DefaultValue = "<DemandFood>"
'idcolumn.DataType = Type.GetType("System.string")
foodtable.Columns.Add(foodemandcolumn)
'a.RetrievePatient(patID)
'add row of data
For i = 0 To ds4.Tables(0).Rows.Count() - 1
'If TextBox1.Text = ds3.Tables(0).Rows(i)(0) Then
row = foodtable.NewRow
row("PatientID") = ds4.Tables(0).Rows(i)("PatientID")
row("Name") = ds4.Tables(0).Rows(i)("Name")
row("DemandFood") = ds4.Tables(0).Rows(i)("DemandFood")
foodtable.Rows.Add(row)
'DataGrid2.SetDataBindinga(ds2,"DemanfFood)
'End If
Next
ds4.Tables.Add(foodtable)
DataGrid2.SetDataBinding(ds4, "Food")
End Function
With the above coding data could not be retrieve to the datagrid
*datagrid couls br filled if the above codes are placed in a Form_Load or
button_Onclick
vitz...