Estoy intentando duplicar registros en una tabla.
Cuando solo intento duplicar en la tabla COMUNIDAD, me crea los 30 registros sin problema:
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
El problema viene cuando intento duplicar registros de la tabla COMUNIDAD y de la tabla MENU del siguiente modo:
Código:
Me tira el siguiente error:Set Rs1 = CreateObject("ADODB.RecordSet") set dnstext1= CreateObject("ADODB.Connection") DnsText1.open = "driver={MySQL};server="&session("servidor")&";uid="&session("usuariobd")&";pwd="&session("contrasenabd")&";database="&session("bd")&"" SqlText1 = "select Max(id) as i from COMUNIDAD" Rs1.Open SqlText1, DnsText1,adOpenDinamic, adLockPessimistic, AdCMDText i=Rs1("i") i=i+1 x=i+30 Rs1.close Set Rs11 = CreateObject("ADODB.RecordSet") set dnstext11= CreateObject("ADODB.Connection") DnsText11.open = "driver={MySQL};server="&session("servidor")&";uid="&session("usuariobd")&";pwd="&session("contrasenabd")&";database="&session("bd")&"" SqlText11 = "select Max(id) as y from MENU" Rs11.Open SqlText11, DnsText11,adOpenDinamic, adLockPessimistic, AdCMDText Y=Rs11("y") Y=Y+1 M=Y+30 Rs11.close 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 do while(y<m) 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 i=i+1 Loop response.write("Comunidades Duplicadas con éxito ¡¡¡¡¡")
[MySQL][ODBC 3.51 Driver][mysqld-4.0.18-nt]Duplicate entry '163' for key 1
Pueden ayudarme plis¿¿¿???
Muchas gracias ¡¡¡