11
« on: November 09, 2017, 09:07:30 AM »
I am trying to use multiple DataSubscribers to write to an SQL database. The issue i am having is each one of my DataSubscribers are making a new row instead of writing data to the same row after the first one makes a new row. I'm not sure how to program this logic in .vb.
Here is the code i have:
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
Using t As New ControlsDBDataSet1.StoreData2DataTable
t.AddStoreData2Row(t.NewRow)
t(0).Data = e.Values(0)
Using ta As New ControlsDBDataSet1TableAdapters.StoreData2TableAdapter
ta.Update(t)
End Using
End Using
End Sub
Private Sub DataSubscriber2_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber2.DataChanged
Using t As New ControlsDBDataSet1.StoreData2DataTable
t.AddStoreData2Row(t.NewRow)
t(0).State = e.Values(0)
Using ta As New ControlsDBDataSet1TableAdapters.StoreData2TableAdapter
ta.Update(t)
End Using
End Using
End Sub
Private Sub DataSubscriber3_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber3.DataChanged
Using t As New ControlsDBDataSet1.StoreData2DataTable
t.AddStoreData2Row(t.NewRow)
t(0).Green = e.Values(0)
Using ta As New ControlsDBDataSet1TableAdapters.StoreData2TableAdapter
ta.Update(t)
End Using
End Using
End Sub
I'm sure this is a simple fix.
Thanks