SoloCodigo
Programación General => Visual Basic 6.0 e inferiores => Mensaje iniciado por: hdr en Viernes 18 de Noviembre de 2005, 01:40
-
holas, les cuento que tengo estas lineas, en el momento RsRES.EOF = TRUE
el execute me da el error no se puede añadir o modificar el registro por que se
necesita un registro relacionado en la tabla Tb_Prodcuto
Me.cmdNuevo.Enabled = True
Me.cmdGuardar.Enabled = False
Me.cmdBuscar.Enabled = True
Me.cmdEliminar.Enabled = True
rs.Fields("IdProducto") = Me.txtProductoF
rs.Fields("IdProveedor") = Me.txtProveedorf
rs.Fields("Cantidad") = Me.txtCantidad
rs.Fields("Precio") = Me.txtPrecio
rs.Fields("IdTipoEntrada") = TipoEntrada(Me.cmbTipoEntrada.Text)
rs.Fields("Fecha") = Me.dtpFecha.Value
Dim com As New ADODB.Command
Dim RsRes As ADODB.Recordset
com.CommandText = "SELECT * FROM tb_Inventario WHERE idproducto= '" & Me.txtProductoF & "'"
Set com.ActiveConnection = Con
com.CommandType = adCmdText
Set RsRes = com.Execute
Dim Inv As Integer
If RsRes.EOF = True Then
Inv = 0
Else
Inv = RsRes.Fields("Cantidad")
End If
Inv = Inv + CInt(Me.txtCantidad)
If RsRes.EOF = True Then
com.CommandText = "Sp_AddInventario"
Else
com.CommandText = "Sp_UpdateInventario"
End If
RsRes.Close
com.CommandType = adCmdStoredProc
Dim pr As ADODB.Parameter
Dim pr2 As ADODB.Parameter
Set pr = com.CreateParameter("@Cantidad", adNumeric, adParamInput, 5, Inv)
Set pr2 = com.CreateParameter("@Producto", adVarWChar, adParamInput, 20, Me.txtProductoF)
com.Parameters.Append pr
com.Parameters.Append pr2
com.Execute
com.CommandType = adCmdText
com.CommandText = "SELECT * FROM tb_Detalles_Producto_Proveedor WHERE Idproducto='" & _
Me.txtProductoF & "' AND IdProveedor='" & Me.txtProveedorf & "'"
Set RsRes = com.Execute
If RsRes.EOF = True Then
Dim Command As New ADODB.Command
Set Command.ActiveConnection = Con
Command.CommandType = adCmdStoredProc
Command.CommandText = "Sp_Add_Detalles_Producto_proveedor"
Dim Prdu As ADODB.Parameter
Dim Prov As ADODB.Parameter
Set Prdu = com.CreateParameter("@Producto", adVarWChar, adParamInput, 20, Me.txtProductoF)
Set Prov = com.CreateParameter("@Proveedor", adVarWChar, adParamInput, 15, Me.txtProveedorf)
Command.Parameters.Append Prdu
Command.Parameters.Append Prov
Command.Execute
End If
rs.Update
actualizar
Set Command = Nothing
Set com = Nothing
ser RsRes = Nothing
el store procedure que me da el problema es
INSERT INTO Tb_Detalle_Producto_Proveedor ( IdProducto, IdProveedor )
VALUES ([@Producto], [@Proveedor]);
CUALQUIER AYUDA ES MUY BIEN RECIBIDA
-
Que tal hernanvid!
Contestando al primero error si es no se puede añadir o modificar el registro por que se necesita un registro relacionado en la tabla Tb_Prodcuto
es por que estas llamando un producto que no existe.
nos cuentas, saludos.
-
eso pensaba yo, pero me asegure y el producto si existe,
intente metiendo los valores desde el codigo total mente seguro de que el producto existia y aun asi me sale el error
-
Que tal!
Mmmm, me imagino entonces que no te esta tomando los parametros como debe ser, ya los rebisaste bien, que la tome bie el valor del parametro, no se me ocurre mas, deberias probar lo haciendo una consulta haber que error te sale.
-
e revisado eso mil veces, ya me toco que hacer otra cosa
pero gracias por la ayuda