Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/10/2008, 08:55
FlashO
 
Fecha de Ingreso: marzo-2008
Mensajes: 42
Antigüedad: 17 años, 1 mes
Puntos: 0
Respuesta: Duplicar registros

Esta parte de código me esta funcionando correctamente:

Código:
do while(i<x)

Set Rs = CreateObject("ADODB.RecordSet")
		set dnstext2= CreateObject("ADODB.Connection")
DnsText2.open = "driver={MySQL};server="&session("servidor")&";uid="&session("usuariobd")&";pwd="&session("contrasenabd")&";database="&session("bd")&""
SqlText ="insert into COMUNIDAD select '"&i&" ',COMUNIDAD, PRIVADO from COMUNIDAD where id=36"
		Rs.Open SqlText, DnsText2,adOpenDinamic, adLockPessimistic, AdCMDText

i=i+1
Loop
En i esta almacenado el id(MAX) de la tabla COMUNIDAD y repito el bucle 30 veces para hacer 30 duplicados del registro que tenga id=36.
Esta parte si la ejecuto sin la otra sentencia funciona perfectamente, el problema viene cuando intento insertar en la tabla MENU duplicados de un registro de la tabla MENU que cumpla las condiciones: comunidad=36 y Menpocision=1.

Código:
Set Rs3 = CreateObject("ADODB.RecordSet")
		set dnstext3= CreateObject("ADODB.Connection")
DnsText3.open = "driver={MySQL};server="&session("servidor")&";uid="&session("usuariobd")&";pwd="&session("contrasenabd")&";database="&session("bd")&""
SqlText3 ="insert into MENU select '"&Y&" ',MenNombre, MenPocision, '"&i&" ', Ocultar from MENU where comunidad=36 AND Menpocision=1"
		Rs3.Open SqlText3, DnsText3,adOpenDinamic, adLockPessimistic, AdCMDText
		response.write(Sqltext3)
Y=Y+1
Loop