I have this sSQL Update formula. The problem is the HOLD field either will contain a Y or a N. I want to keep all the Y. But when it runs against each row it only leaves the first Y and not any others.
icount = 0 'set the value to count the number of tickets
DataSet1.AcceptChanges()
For Each rowX As DataRow In DataSet1.Lot_Tracking_Hist.Rows
sSQL = "INSERT INTO [Lab Table] (LotNumber, TDate, FGNumber, Shift," & _
"TTime, Qty, OrderNumber, Batch, Code, Hold)" & _
" Values " & _
"('" & rowX.Item("LOTNUM_72").ToString & "'," & _
"#" & rowX.Item("TNXDTE_72") & "#," & _
"'" & rowX.Item("PRTNUM_72").ToString & "'," & _
"'" & rowX.Item("USRNAM_72").ToString & "'," & _
"'" & rowX.Item("TNXTIM_72").ToString & "'," & _
"'" & rowX.Item("TNXQTY_72").ToString & "'," & _
"'" & rowX.Item("ORDNUM_72").ToString & "'," & _
"'" & rowX.Item("UDFREF_72").ToString.Substring(0, 6) & "'," & _
"'" & rowX.Item("UDFREF_72").ToString.Substring(rowX.Item("UDFREF_72").ToString.Length - 19, 9) & "'," & _
"'" & rowX.Item("SUPCDE_01") & "')"
With objCommand ' this portion identifies the connection that will supply the data to be entered during the commands
.Connection = oOleDbConnection
.CommandText = sSQL
.CommandType = CommandType.Text
.ExecuteNonQuery()
End With
sSQL = "UPDATE [Lab Table] SET [Lab Table].Hold= NULL WHERE ((([Lab Table].Hold)='N'));"
With objCommand
.Connection = oOleDbConnection
.CommandText = sSQL
.CommandType = CommandType.Text
.ExecuteNonQuery()
End With
icount = 0 'set the value to count the number of tickets
DataSet1.AcceptChanges()
For Each rowX As DataRow In DataSet1.Lot_Tracking_Hist.Rows
sSQL = "INSERT INTO [Lab Table] (LotNumber, TDate, FGNumber, Shift," & _
"TTime, Qty, OrderNumber, Batch, Code, Hold)" & _
" Values " & _
"('" & rowX.Item("LOTNUM_72").ToString & "'," & _
"#" & rowX.Item("TNXDTE_72") & "#," & _
"'" & rowX.Item("PRTNUM_72").ToString & "'," & _
"'" & rowX.Item("USRNAM_72").ToString & "'," & _
"'" & rowX.Item("TNXTIM_72").ToString & "'," & _
"'" & rowX.Item("TNXQTY_72").ToString & "'," & _
"'" & rowX.Item("ORDNUM_72").ToString & "'," & _
"'" & rowX.Item("UDFREF_72").ToString.Substring(0, 6) & "'," & _
"'" & rowX.Item("UDFREF_72").ToString.Substring(rowX.Item("UDFREF_72").ToString.Length - 19, 9) & "'," & _
"'" & rowX.Item("SUPCDE_01") & "')"
With objCommand ' this portion identifies the connection that will supply the data to be entered during the commands
.Connection = oOleDbConnection
.CommandText = sSQL
.CommandType = CommandType.Text
.ExecuteNonQuery()
End With
sSQL = "UPDATE [Lab Table] SET [Lab Table].Hold= NULL WHERE ((([Lab Table].Hold)='N'));"
With objCommand
.Connection = oOleDbConnection
.CommandText = sSQL
.CommandType = CommandType.Text
.ExecuteNonQuery()
End With