Dear All
I need some help figuring this one out
I have a Datasubscriber2 that inserts some data into a MS SQL DB, but every record is inserted twice in the DB
I have double checked the PLC code, debugged the AdvancedHMI code, they are only firering once, here is my
code:
Private Sub DataSubscriber25_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber25.DataChanged
If e.ErrorId = 0 Then
If e.Values(0) = True Then
Using Con As New SqlConnection("Data Source=192.168.100.100;Initial Catalog=DB;Persist Security Info=True;User ID=Tarzan;Password=****")
Dim command As New SqlCommand("insert into dbo.Products(UPID, XPOS, YPOS, Error, Employee, Employee2) values(@UPID, @xpos, @ypos, @error, @employee, @employee2)", Con)
command.Parameters.Add("@UPID", SqlDbType.Int).Value = BasicLabel16.Value
command.Parameters.Add("@xpos", SqlDbType.Int).Value = BasicLabel2.Value
command.Parameters.Add("@ypos", SqlDbType.Int).Value = BasicLabel3.Value
command.Parameters.Add("@error", SqlDbType.Int).Value = BasicLabel4.Value
command.Parameters.Add("@employee", SqlDbType.Int).Value = BasicLabel5.Value
command.Parameters.Add("@employee2", SqlDbType.Int).Value = BasicLabel33.Value
If Con.State.ToString <> "Open" Then
Con.Open()
End If
command.ExecuteNonQuery()
If command.ExecuteNonQuery() <> 1 Then
Con.Close()
Con.Dispose()
End If
End Using
EthernetIPforCLXCom1.Write("DB_Tricker_1", 0)
End If
End If
End Sub
/Holmux