Hola amigos, tengo dos FOR...para comparar dos tablas...tendo dos tablas que contienen una información de productos, quiero compararlos por un campo que tienen numérico si el producto existe en una de las tablas y si no existe que lo inserte...pero el for se queda en el for i y no me sube al for x....en el for x tengo la tabla que debe recibir los productos nuevos...mirar
Código:
For x = 0 To datasets.Tables("Producto").Rows.Count - 1
'''''''''''''''''''''recibe los productos nuevos''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
nfges = datasets.Tables("Producto").Rows(x).Item("Namilia").ToString
famges = datasets.Tables("Producto").Rows(x).Item("Nomamilia").ToString
For i = 0 To dataset.Tables("[Familias de producto]").Rows.Count - 1
'''''''''''''''''''''''''''''tiene los nuevos para mandarselos a la otra tabla'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
nftpv = dataset.Tables("[producto]").Rows(i).Item("N").ToString
famtpv = dataset.Tables("[producto]").Rows(i).Item("Nombre").ToString
'SIN NO HAY NINGUN producto CARGO TODAS LAS QUE ESTÁN en la otra tabla
If datasets.Tables("FamiliasDeProducto").Rows.Count = 0 Then
comandos.CommandType = CommandType.Text
comandos.CommandText = "Insert Into Producto (Namilia,Nomamilia) Select N,Nombre FROM [MS Access;DATABASE=" & TextBox1.Text & "].[producto] order by N"
adaptadores.SelectCommand = comandos
adaptadores.Fill(datasets, "Producto")
Exit For ' Y SALGO DEL FOR TERMINO LA OPERACIÓN
'SI EN CAMBIO SI TENGO productos COMPARO SI LOS NÚMEROS COINCIDEN Y SI NO ES ASÍ...ACTUALIZO EL QUE FALTE
Else
If nftpv = nfges Then
Else
Dim com = conexion.CreateCommand
com.CommandType = CommandType.Text
com.CommandText = "UPDATE Producto SET Namilia = '" & nftpv & "', Nomamilia = '" & famtpv & "'"
'com.Parameters.AddWithValue("@Id", nftpv = dataset.Tables("[producto]").Rows(i).Item("N"))
adaptadores.UpdateCommand = com
adaptadores.Fill(datasets, "Producto")
End If
End If
Next
Next