Operation is not allowed when the object is closed

31/08/2004 - 05:34 por leon | Informe spam
saludos listeros.

Estoy obteniendo este error cuando trato de correr el siguiente codigo.
"Operation is not allowed when the object is closed"

Solo les voy a mostrar el pedazo donde me esta sacando el error, lo demas
lo omití porque no es necesario, como cerrar la conexion y los recordset.

las consultas corren y ejecutan bien.
El error ocurre en esta linea:
esta cinco lineas antes del final:

"if rst2.EOF = false then"



dim strMaxInmueble

'se crean dos rs, rst = select a tlbBienes
' strMax = para obtener el maximo Inmueble
set rst = Server.CreateObject("ADODB.Recordset")
set rst2 = Server.CreateObject("ADODB.Recordset")
set rstMax = Server.CreateObject("ADODB.Recordset")


'Se busca el consecutivo para el negocio
strSQL = "SELECT strNumeroInmueble AS Ninmueble" & _
" FROM tblBienes"

rst.Open strSQL, strRutaConexion
if rst.EOF = true then
strNumeroInmueble = mid(Trim(SessionIdRegional),1,2) & "0001"
else
'ahora obtenemos el máximo número del negocio
strSQL = "SELECT
Max(CLng(Mid(strNumeroInmueble,Len([strNumeroInmueble])-3,Len([strNumeroInmu
eble])))) AS Ninmueble" & _
" FROM tblBienes"

rstMax.Open strSQL, strRutaConexion
strMaxInmueble = rstMax.Fields("Ninmueble")
'aumentamos en 1 el negocio
strMaxInmueble = CLng(strMaxInmueble) + 1
'necesitamos concatenar los ceros a la izquierda
if len(strMaxInmueble) = 1 then
strMaxInmueble = "000" & strMaxInmueble
else
if len(strMaxInmueble) = 2 then
strMaxInmueble = "00" & strMaxInmueble
else
if len(strMaxInmueble) = 3 then
strMaxInmueble = "0" & strMaxInmueble
end if
end if
end if
'concatenamos todo para obtener el número negocio final
strNumeroInmueble = mid(Trim(SessionIdRegional),1,2) & strMaxInmueble
end if

strSQL = ""
strSQL = "INSERT INTO tblBienes ( strNumeroInmueble, " & _
" strIdRegional, strNumeroNegocio, strIdTipoInmueble," & _
" bytGrupoInmueble, strEstadoBien, strCuentaConavi," & _
" dblValorConavi, strIdPerito, dblValorAvaluo, dblValorGastos," & _
" strLocalizacion, strUrbanizacion, strMunicipio, strBarrio," & _
" strIdEstrato, lngArea, strMatriculaIn, strIdPiso, " & _
" strIdMuro, strIdTecho, strIdCocina, bytNumeroAlcobas, " & varCampos &
" )" & _
" VALUES (" & strNumeroInmueble & ", " & _
" " & strIdRegional & ", " & strNumeroNegocio & ", '" &
strIdTipoInmueble & "'," & _
" '" & bytGrupoInmueble & "', " & strEstadoBien & ", " &
strCuentaConavi & ", " & _
" " & dblValorConavi & ", '" & strIdPerito & "', " & dblValorAvaluo & ",
" & dblValorGastos & ", " & _
" '" & strLocalizacion & "', '" & strUrbanizacion & "', '" &
strMunicipio & "', '" & strBarrio & "', " & _
" '" & strIdEstrato & "', " & lngArea & ", '" & strMatriculaIn & "', '"
& strIdPiso & "', " & _
" '" & strIdMuro & "', '" & strIdTecho & "', '" & strIdCocina & "', " &
bytNumeroAlcobas & ", " & varValores & ")"

objConx.Execute(strSQL)

'Si el negocio tiene asociado un Bien y una Obligacion, entonces
' se coloca el campo strEstadoNeg de la tabla tblNegocios en 2 Contabilizado
strSQL = "SELECT tblNegocios.strNumeroNegocio, tblNegocios.strEstadoNeg" &
_
"FROM (tblNegocios INNER JOIN tblBienes ON
tblNegocios.strNumeroNegocio" & _
" = tblBienes.strNumeroNegocio) INNER JOIN tblObligaciones ON
tblNegocios.strNumeroNegocio" & _
" = tblObligaciones.strNumeroNegocio" & _
" WHERE tblNegocios.strEstadoNeg = '" & strNumeroNegocio & "'"


objConx.Open strRutaConexion
rst2.Open strSQL, strRutaConexion
if rst2.EOF = false then
strSQL = "UPDATE tblNegocios SET tblNegocios.strEstadoNeg = 2" & _
" WHERE strNumeroNegocio = '" & strNumeroNegocio & "'"
objConx.Execute(strSQL)
end if


De antemano os agradezco

leon

Preguntas similare

Leer las respuestas

#6 leon
31/08/2004 - 22:38 | Informe spam
Sashka, o sea que lo que no debo hacer es cuando abra el recordset, hacerlo
de esta manera:

rst2.Open strSQL

Bueno por el momento, voy a probar lo que me dices haber como me va.
De antemano te agredezco,

leon.


"Sashka" wrote in message
news:ubn$
Mostrar la cita
http://support.microsoft.com/defaul...?scid=http://support.microsoft.com:80/support/kb/articles/Q191/5/72.ASP&NoWebContent=1
Mostrar la cita
cierro
Mostrar la cita
insertar
Mostrar la cita
Max(CLng(Mid(strNumeroInmueble,Len([strNumeroInmueble])-3,Len([strNumeroInmu
Mostrar la cita
&
Mostrar la cita
_
Mostrar la cita
&
Mostrar la cita
#7 Sashka
31/08/2004 - 23:10 | Informe spam
Noooooooo... claro que tienes que pasarle la cadena del sql pero en
lugar de pasarle la cadena de conexión como lo haces..
rst2.Open strSQL, strRutaConexion

Debes pasarle el objecto connection...
strRutaConexion = "la cadena de conexion"
Set objConx = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")
objConx.Open strProvider
SQL= "el sql que necesitas"
RS.Open SQL, ObjConx
...
...
...
RS.close
set RS = nothing
objConX.close
Set objConx = nothing

Sashka
MS MVP Access

"leon" escribió en el mensaje
news:
Mostrar la cita
hacerlo
Mostrar la cita
implícitos
Mostrar la cita
de
Mostrar la cita
no
Mostrar la cita
veces
Mostrar la cita
http://support.microsoft.com/defaul...?scid=http://support.microsoft.com:80/support/kb/articles/Q191/5/72.ASP&NoWebContent=1
Mostrar la cita
lo
Mostrar la cita
lo
Mostrar la cita
Max(CLng(Mid(strNumeroInmueble,Len([strNumeroInmueble])-3,Len([strNumeroInmu
Mostrar la cita
dblValorGastos,"
Mostrar la cita
&
Mostrar la cita
strMatriculaIn
Mostrar la cita
&
Mostrar la cita
"'"
Mostrar la cita
tblNegocios.strEstadoNeg
Mostrar la cita
#8 leon
01/09/2004 - 05:30 | Informe spam
Hola Sashka, el error era una conexion que ya tenia abierta mas arriba, al
fin lo encontré.
Os abradezco por la grandiosa ayuda.

Ahora Sashka, ya que me hablas de conexiones implicitas, y que creo las
estoy haciendo mal,
cual es la forma correctade hacerlo?

saludos,

leon.



"Sashka" wrote in message
news:#
Mostrar la cita
ésto
Mostrar la cita
.
Mostrar la cita
lugar
Mostrar la cita
que
Mostrar la cita
recordset
Mostrar la cita
pool
Mostrar la cita
http://support.microsoft.com/defaul...?scid=http://support.microsoft.com:
80/support/kb/articles/Q191/5/72.ASP&NoWebContent=1
Mostrar la cita
.
Mostrar la cita
tblNegocios.strEstadoNeg
Mostrar la cita
Max(CLng(Mid(strNumeroInmueble,Len([strNumeroInmueble])-3,Len([strNumeroInmu
Mostrar la cita
final
Mostrar la cita
_
Mostrar la cita
strBarrio,"
Mostrar la cita
&
Mostrar la cita
strIdCocina
Mostrar la cita
entonces
Mostrar la cita
ON
Mostrar la cita
#9 leon
01/09/2004 - 05:30 | Informe spam
Hola Sashka, el error era una conexion que ya tenia abierta mas arriba, al
fin lo encontré.
Os abradezco por la grandiosa ayuda.

Ahora Sashka, ya que me hablas de conexiones implicitas, y que creo las
estoy haciendo mal,
cual es la forma correctade hacerlo?

saludos,

leon.



"Sashka" wrote in message
news:#
Mostrar la cita
ésto
Mostrar la cita
.
Mostrar la cita
lugar
Mostrar la cita
que
Mostrar la cita
recordset
Mostrar la cita
pool
Mostrar la cita
http://support.microsoft.com/defaul...?scid=http://support.microsoft.com:
80/support/kb/articles/Q191/5/72.ASP&NoWebContent=1
Mostrar la cita
.
Mostrar la cita
tblNegocios.strEstadoNeg
Mostrar la cita
Max(CLng(Mid(strNumeroInmueble,Len([strNumeroInmueble])-3,Len([strNumeroInmu
Mostrar la cita
final
Mostrar la cita
_
Mostrar la cita
strBarrio,"
Mostrar la cita
&
Mostrar la cita
strIdCocina
Mostrar la cita
entonces
Mostrar la cita
ON
Mostrar la cita
#10 Sashka
01/09/2004 - 14:21 | Informe spam
Lo que te dije en el post anterior debes usar conexiones
explícitasen
lugar de pasarle la cadena de conexión (conexión implícita) como lo
haces..
rst2.Open strSQL, strRutaConexion

Debes pasarle el objecto connection...(conexion explícita)

strRutaConexion = "la cadena de conexion"
Set objConx = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")
objConx.Open strProvider
SQL= "el sql que necesitas"
RS.Open SQL, ObjConx
...
...
...
RS.close
set RS = nothing
objConX.close
Set objConx = nothing


"leon" escribió en el mensaje
news:
Mostrar la cita
decir
Mostrar la cita
http://support.microsoft.com/defaul...?scid=http://support.microsoft.com:
Mostrar la cita
"'"
Mostrar la cita
la
Mostrar la cita
no
Mostrar la cita
siguiente
Mostrar la cita
error,
Mostrar la cita
&
Mostrar la cita
Max(CLng(Mid(strNumeroInmueble,Len([strNumeroInmueble])-3,Len([strNumeroInmu
Mostrar la cita
&
Mostrar la cita
_
Mostrar la cita
&
Mostrar la cita
'"
Mostrar la cita
2
Mostrar la cita
tblObligaciones
Mostrar la cita
&
Mostrar la cita
Ads by Google
Search Busqueda sugerida