JamesBrian
asked on
Refresh datagrid using timer event
Hi all,
I am filling my Datagrid like this :
Private Sub LoadData()
'Construct data adapter
SelectCmdString = "select * from SMSQUEUE WHERE Acknowledged=0 order by SMSQueueID"
da = New SqlDataAdapter(SelectCmdSt ring, conn)
da.Fill(ds, "SMSQUEUE")
LabelID.DataBindings.Add(" Text", ds, "SMSQUEUE.smsqueueid")
LabelDate.DataBindings.Add ("Text", ds, "SMSQUEUE.createdon")
LabelDestination.DataBindi ngs.Add("T ext", ds, "SMSQUEUE.destination")
LabelDescription.DataBindi ngs.Add("T ext", ds, "SMSQUEUE.description")
DataGrid1.SetDataBinding(d s, "SMSQUEUE")
Timer1.Interval = CInt(myInterval) * 1000
Timer1.Enabled = True
End Sub
So far so good.
In my timer event I want to refresh the data in the datagrid:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
LoadData()
End Sub
I have tried setting da= nothing and ds=nothing but that did'nt work.
How can I refresh the data without getting errormessage : This would cause two bindings in the collection to bind to the same property. Parameter name: binding
I am filling my Datagrid like this :
Private Sub LoadData()
'Construct data adapter
SelectCmdString = "select * from SMSQUEUE WHERE Acknowledged=0 order by SMSQueueID"
da = New SqlDataAdapter(SelectCmdSt
da.Fill(ds, "SMSQUEUE")
LabelID.DataBindings.Add("
LabelDate.DataBindings.Add
LabelDestination.DataBindi
LabelDescription.DataBindi
DataGrid1.SetDataBinding(d
Timer1.Interval = CInt(myInterval) * 1000
Timer1.Enabled = True
End Sub
So far so good.
In my timer event I want to refresh the data in the datagrid:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
LoadData()
End Sub
I have tried setting da= nothing and ds=nothing but that did'nt work.
How can I refresh the data without getting errormessage : This would cause two bindings in the collection to bind to the same property. Parameter name: binding
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
LoadData()
End Sub
with
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
da.Fill(ds, "SMSQUEUE")
End Sub
Roger