Problem with Web Services and Updating datagrid on windows form.

I have a simple web service that returns a dataset with one table in it.
I've managed to show the data on a datagrid on a form with an update button.
however, I would like the data to get updated every 5 min.
I've setup a timer with Elapsed trigger to update the gride by calling the web service and refresh the grid.

problem: my data grid does not even show up on the form when I use the timer.

code: very simple see below.

Private Timer1 As New System.Timers.Timer(10000)
Dim sales As New org.mystore.www.BookstoreSales

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As  System.EventArgs) Handles MyBase.Load
  Timer1.AutoReset = True
  AddHandler Timer1.Elapsed, AddressOf TimerFired
End Sub

Public Sub TimerFired(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
 
UpdateGrid()
End Sub

Private Sub UpdateGrid()
  StatusBar1.Refresh()
 
StatusBar1.Text = "Last Update: " & Now().ToShortTimeString
 
DataGrid1.Refresh()
 
DataGrid1.DataSource = sales.GetSales.Tables("BookstoreSales")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
  Timer1.Enabled = True
  StatusBar1.Text = "Timer Started"
End Sub



Answer this question

Problem with Web Services and Updating datagrid on windows form.

  • fap99

    Private Timer1 As New System.Timers.Timer(10000)

    "10000" is very short time.. you can increase this time to (i.e  50000) I think your Web Services Update time is not enough to Updating Completely..



  • Avi harush

    Is there a way to refresh web service every time underlying data change....I need fast response when my data change to automaticlly refresh grids on users application

  • Mynor Ivan Muralles MSFT

    Hi,
    I've changed that value all the way to 15 seconds and still didn't give me any result.
    my web service is local and my test shows sub-seconds response.

    Thank you for your comment.

    -JJ


  • Problem with Web Services and Updating datagrid on windows form.