Visual Basic - Ayuda conexion error 3704 objeto closed

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Ayuda conexion error 3704 objeto closed

Publicado por Martin (28 intervenciones) el 31/01/2014 20:00:14
Buenas tardes a todos, tengo una aplicacion en vb 6 conectada a bd sql 2008 en la cual intento mostrar los campos de una bd en textbox, cuando el usuario teclea un codigo se debe buscar y mostrar los campos de la table en los demas textbox pero me da error 3704 el objeto no se puede mostrar mientras este cerrado :

Private Sub Form_Activate()
'
CREAMOS CONEXION (las variables las declare globales en un modulo)
Set CON = New ADODB.Connection
With CON
.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=MIBD; Data Source=MISERVER"
End With
'CREAMOS RECORDSET
Set ORS = New ADODB.Recordset
SQL = "SELECT * FROM MIBD"
ORS.Open SQL, CON, adOpenDynamic, adLockOptimistic
ORS.MoveFirst
TxtIDProducto1.SetFocus

End Sub

Private Sub TxtIDProducto1_LostFocus()

'INICIAMOS RECORDSET
ORS.MoveFirst
'INICIAMOS CICLO PARA VALIDAR EL ARTICULO INGRESADO
Do While Not ORS.EOF
If ORS("ItemCode").Value = TxtIDProducto1.Text Then
ItemCode = ORS("ItemCode").Value
TxtCantidad1.SetFocus
TxtDescripcion1.Text = ORS("Description").Value
TxtPrecio1.Text = ORS("CostPriceStandard").Value
TxtVenta1.Text = ORS("SalesPackagePrice").Value
ORS.Close
CON.Close
Exit Do
Exit Sub
Else
TxtIDProducto1.SetFocus
ORS.MoveNext
End If
Loop
If ItemCode = "" Then
MsgBox "ERROR: Código Incorrecto !", vbCritical, ("FORM1")
TxtIDProducto1.SetFocus
End If
ItemCode = ""
End Sub

Private Sub TxtIDProducto2_LostFocus()
'INICIAMOS RECORDSET
ORS.MoveFirst
End If
'INICIAMOS CICLO PARA VALIDAR EL ARTICULO INGRESADO
Do While Not ORS.EOF
If ORS("ItemCode").Value = TxtIDProducto2.Text Then
ItemCode = ORS("ItemCode").Value
TxtCantidad2.SetFocus
TxtDescripcion2.Text = ORS("Description").Value
TxtPrecio2.Text = ORS("CostPriceStandard").Value
TxtVenta2.Text = ORS("SalesPackagePrice").Value
ORS.Close
CON.Close
Exit Do
Exit Sub
Else
TxtIDProducto2.SetFocus
ORS.MoveNext
End If
Loop
If ItemCode = "" Then
MsgBox "ERROR: Código Incorrecto !", vbCritical, ("FORM1")
TxtIDProducto2.SetFocus
End If
ItemCode = ""
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder