Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Problema Error 3705 operation is not allowed when the object is open

Estas en el tema de Problema Error 3705 operation is not allowed when the object is open en el foro de Visual Basic clásico en Foros del Web. HOla... Soy Nueva en este foro y me gustaria que me ayudaran con el sgte error: error 3705 operation is not allowed when the object ...
  #1 (permalink)  
Antiguo 12/11/2008, 09:45
 
Fecha de Ingreso: noviembre-2008
Mensajes: 131
Antigüedad: 15 años, 5 meses
Puntos: 0
Problema Error 3705 operation is not allowed when the object is open

HOla... Soy Nueva en este foro y me gustaria que me ayudaran con el sgte error:

error 3705 operation is not allowed when the object is open,

y una parte del codigo que tengo es este:

Private Sub Cargar() ' esta es la conexion a la base y el llenado de combo

Dim CantReg As Variant

Connect.Provider = "SQLOLEDB"
Connect.Open "Driver={SQL Server};" & _
"Server=" & macForm.ConnInfo.Server & _
";Uid=" & macForm.ConnInfo.User & _
";Pwd=" & macForm.ConnInfo.pwd & _
";Database=" & macForm.ConnInfo.DB

Set Rsl = New ADODB.Recordset
Set Rs2 = New ADODB.Recordset

Cadena_SQL = "SELECT COUNT(*) as cus_name FROM OECOTIZACION_SQL"
Cadena_SQL_2 = "SELECT * FROM OECOTIZACION_SQL"

Rsl.Open Cadena_SQL, Connect, adOpenDynamic, adLockPessimistic
Rs2.Open Cadena_SQL_2, Connect, adOpenDynamic, adLockPessimistic

CantReg = Rsl.Fields("cus_name")

Rs2.MoveFirst

For i = 0 To CantReg - 1
Combo_Cliente.AddItem Rs2.Fields("cus_name")
Rs2.MoveNext

Next i

End Sub

y aqui tengo el codigo que me adiciona:

Private Sub Cmd_Aceptar_Click()

'Fra_Funciones.Visible = True
'Fra_Adicionar.Visible = False

Rs2.AddNew
Rs2.Fields("cot_date") = Text_Fecha.Text
Rs2.Fields("cot_number") = Text_Id.Text
Rs2.Fields("cus_name") = Combo_Cliente.Text
Rs2.Fields("item_no") = Text_Producto.Text
Rs2.Fields("search_desc") = Text_Product.Text
Rs2.Fields("Especific_prod") = Text_Especific.Text
Rs2.Fields("item_desc_2") = Text_Presentacion.Text
Rs2.Fields("qty_prod") = Text_Cantidad.Text
Rs2.Fields("prc_or_disc_1") = Text_Precio.Text
Rs2.Fields("end_prc") = Text_Validez.Text
Rs2.Fields("pay_term") = Combo_terminos.Text
Rs2.Fields("addr_1") = Text_Direccion.Text
Rs2.Fields("lead_time") = Text_Reque.Text
Rs2.Fields("cot_sales") = Combo_Vendedor.Text
Rs2.Fields("cot_Observ") = Text_Observ.Text

Cargar

End Sub
  #2 (permalink)  
Antiguo 12/11/2008, 10:19
 
Fecha de Ingreso: noviembre-2005
Mensajes: 751
Antigüedad: 18 años, 6 meses
Puntos: 13
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Hola

En que linea te marca el error?, puede ser que tengas la conexión a la bd abierta anteriormente?

--Saludos--
  #3 (permalink)  
Antiguo 12/11/2008, 10:23
 
Fecha de Ingreso: noviembre-2008
Mensajes: 131
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Hola Insomnia,

mira la conexion solamente esta ahi ese es como el form load.
y el error me sale en:

Connect.Provider = "SQLOLEDB"

Gracias por tu interes.
  #4 (permalink)  
Antiguo 12/11/2008, 10:42
 
Fecha de Ingreso: noviembre-2005
Mensajes: 751
Antigüedad: 18 años, 6 meses
Puntos: 13
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Hola

Yo para conectar a una bd SQL Server 2005 utilizo la siguiente cadena de conexión:

Código:
bd.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=Usuario;Password=Pass;Initial Catalog=NombreBD;Data Source=Servidor"
Donde usuario es el usuario con el que me conecto a la bd, Pass su pasword, NombreBD es el nombre de la bd y Servidor es el nombre del equipo en el que tengo la BD.

--Saludos--
  #5 (permalink)  
Antiguo 12/11/2008, 10:52
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Haciendo una pequeña deducción creo que ya tenías abierta la conexión. Porque en el evento Click de Cmd_Aceptar estás recuperando algunos datos del Recordset (que obviamente fueron obtenidos con una conexión) y llamas a la función Cargar, que trata de volver a abrir una conexión. Así que tratas de cambiar el Provider ya teniendo abierta la conexión, por eso supongo que se produce el error.
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #6 (permalink)  
Antiguo 12/11/2008, 11:02
 
Fecha de Ingreso: noviembre-2008
Mensajes: 131
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Insomnia...


lo probe pero aun no funciona, de todas maneras si depronto puedes tener otra solucion me lo comentas.


gracias
  #7 (permalink)  
Antiguo 12/11/2008, 11:04
 
Fecha de Ingreso: noviembre-2008
Mensajes: 131
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problema Error 3705 operation is not allowed when the object is open

David y que suieres....?

Gracias
  #8 (permalink)  
Antiguo 12/11/2008, 11:07
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Que uses una única conexión (o sea, no volver a conectar en la función Cargar) o cerrar la conexión anterior antes de volver a abrir una nueva conexión.
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #9 (permalink)  
Antiguo 12/11/2008, 11:22
 
Fecha de Ingreso: noviembre-2008
Mensajes: 131
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problema Error 3705 operation is not allowed when the object is open

David!!! No se como no lo pense antes..

Gracias. Estos foros son una maravilla!!!

Quite el cargar que lo llamaba en el adicionar. y solo la llamo una vez.

Gracias
  #10 (permalink)  
Antiguo 12/11/2008, 13:26
 
Fecha de Ingreso: noviembre-2008
Mensajes: 131
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Ahora tengo el siguiente error pero en el Consultar:

Me puedes ayudar?

object doesn´t support named arguments

mira mi codigo:
obviamente tiene la misma funcion de cargar.
Private Sub Cmd_Aceptar1_Click() ' este es el de consultar


Cadena_SQL = "Select * from OECOTIZACION_SQL"
StrSql = ""

If Text_Fecha.Text <> "" Then
StrSql = StrSql + "cot_date=" & Text_Fecha.Text + " and "
End If

If Text_Id.Text <> "" Then
StrSql = StrSql + "cot_number=" & Text_Id.Text + " and "
End If

If Combo_Cliente.Text <> "" Then
StrSql = StrSql + "cus_name=" & Combo_Cliente.Text
End If

If Text_Producto.Text <> "" Then
StrSql = StrSql + "item_no=" & Text_Producto.Text
End If

If Text_Product.Text <> "" Then
StrSql = StrSql + "search_desc=" & Text_Product.Text
End If

If Text_Especific.Text <> "" Then
StrSql = StrSql + "Especific_prod=" & Text_Especif.Text
End If

If Text_Presentacion.Text <> "" Then
StrSql = StrSql + "item_desc_2=" & Cmd_present.Text
End If

If Text_Cantidad.Text <> "" Then
StrSql = StrSql + "qty_prod=" & Text_Presentacion.Text
End If

If Text_Precio.Text <> "" Then
StrSql = StrSql + "prc_or_disc_1=" & Text_Precio.Text
End If

If Text_Validez.Text <> "" Then
StrSql = StrSql + "end_prc=" & Text_Validez.Text
End If

If Combo_terminos.Text <> "" Then
StrSql = StrSql + "pay_term=" & Combo_terminos.Text
End If

If Text_Direccion.Text <> "" Then
StrSql = StrSql + "addr_1=" & Text_Direccion.Text
End If

If Text_Reque.Text <> "" Then
StrSql = StrSql + "lead_time=" & Text_Reque.Text
End If

If Combo_Vendedor.Text <> "" Then
StrSql = StrSql + "cot_sales=" & Combo_Vendedor.Text
End If

If Text_Observ.Text <> "" Then
StrSql = StrSql + "cot_Observ=" & Text_Observ.Text
End If

If StrSql <> "" Then
Cadena_SQL = Cadena_SQL + " where " + StrSql

cadena = Cadena_SQL
desde = Len(cadena)
hasta = (desde - 5)
Cadena_SQL = Mid(cadena, 1, hasta)

End If

Connect.RecordSource = Cadena_SQL ' AQUI ME SALE EL ERROR
'Rs2.Refresh
Fra_Funciones.Visible = True
Fra_Consultar.Visible = False
End Sub
  #11 (permalink)  
Antiguo 13/11/2008, 02:45
Colaborador
 
Fecha de Ingreso: enero-2008
Ubicación: Unas veces aquí, otras veces allí
Mensajes: 1.482
Antigüedad: 16 años, 3 meses
Puntos: 37
Respuesta: Problema Error 3705 operation is not allowed when the object is open

Cita:
Iniciado por natalyro Ver Mensaje
Ahora tengo el siguiente error pero en el Consultar:

Me puedes ayudar?

object doesn´t support named arguments

mira mi codigo:
obviamente tiene la misma funcion de cargar.
Private Sub Cmd_Aceptar1_Click() ' este es el de consultar

......

Connect.RecordSource = Cadena_SQL ' AQUI ME SALE EL ERROR
'Rs2.Refresh
Fra_Funciones.Visible = True
Fra_Consultar.Visible = False
End Sub
Por el código anterior deduzco que Connect es una conexión a la base de datos y el objeto Connection no tiene la propiedad RecordSource (que es de un control tipo Data).

Debes aplicar la consulta en la apertura de un recordset:

rscordset.Open Cadena_SQL, conexion

Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:25.