Link to home
Start Free TrialLog in
Avatar of Dan Flood
Dan Flood

asked on

DataSet update via a TIMER

Hi, I cannot seem to get a textbox to update on the timer value - the record count should go up and down, but it just stays the same:

...CODE FOR TIMER1
        Dim ready As String
   
        DataReadyPallets1.GetChanges()
        SqlDataAdapter1.Update(DataReadyPallets1)
        SqlDataAdapter1.Fill(DataReadyPallets1)
        ready = DataReadyPallets1.tblpallets.Rows.Count.ToString
        TextBox1.Text = " READY PALLETS: " & ready
        TextBox2.Text = Now()
...END

I know I am doing something foolish, but no time to figure it out.  Thanks!
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

ADD...

textbox2.refresh
The GetChanges method returns a DataTable object.  You need to pass that into your Update method like this:


    SqlDataAdapter1.Update(DataReadyPallets1.GetChanges())
Avatar of Dan Flood
Dan Flood

ASKER

Hi,

This now causes an exception error and crashes the program :

      Dim ready As String

        SqlDataAdapter1.Update(DataReadyPallets1.GetChanges())     <-- NULL EXCEPTION ERROR.
        ready = DataReadyPallets1.tblpallets.Rows.Count.ToString
        TextBox1.Text = " READY PALLETS: " & ready
        TextBox2.Text = Now()

Also, the textbox2 is rfreshing OK - its a data issue.
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That just hides the error, it doesn't fix the problem :-(

Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed

        Dim ready As String

        Try
            SqlDataAdapter1.Update(DataReadyPallets1.GetChanges())
            ready = DataReadyPallets1.tblpallets.Rows.Count.ToString
            TextBox1.Text = " READY PALLETS: " & ready
            TextBox2.Text = Now()
        Catch exp As System.ArgumentNullException
            TextBox1.Text = "Update Error."
        End Try
    End Sub
I found the solution myself, but your comment was the closest to helping :) thanks