Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop help!!

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi, I am building a SQL insert string that is in a "do while not rs.eof loop" this generates multi inserts based on a changing value, lets say 5. If you copy the HTML source code you will see thresults that this ASP code below is generating.

The issue is the each insert statement generated needs a different "linktoLuniqueID" which you can see i am using time stamps to generate this. I thought a for loop would do this but when sitting inside a do while loop i am just generating the same id for each statement, this cause issues primary key violations.

Does anyone know how i can get a unique id in to this sql string?

Thanks


ASP CODE
Code:
linktoLuniqueID = right(year(now),2)&month(now)&day(now)&hour(now)&minute(now)&second(now)

	Dim i
	For i=0 to 5
	Do while not rstemp2.eof
	
	contactUniqueid = rstemp2("uniqueid")
	
		
	mySQLupdatelinkto = "INSERT INTO wce_linkto (LuniqueID, LUTableName, LEntityID, LETableName) VALUES ('"&(linktoLuniqueID)&i &"', '"&("wce_history")&"','"&contactUniqueid&"','"&("wce_contact")&"')"
	'call updateDatabase(mySQLupdatelinkto, rstemplinkto, "continueSendingcm1")
		

	response.write(mySQLupdatelinkto&"</br>")


	rstemp2.movenext
	loop

	Next


SOURCE HTML

Code:
<html>
<head>

</head>

<body>
<table border="0" width="100%" bgcolor="#999999" 

cellpadding=0 cellspacing=0 align="center" >

		
			<tr bgcolor="#999999" height=35 

valign=center>
				<td>
					<img 

src="./images/cleardot.gif" height="1" width="0">
					<img 

src="./images/npro.gif">
				</td>
				<td align=right>
						<img 

src="./images/login_banner.jpg">
				</td>
			</tr>
				<tr bgcolor="#CCCCCC">
					<td colspan=2>
						<table 

border=0 width=100% cellpadding=0 cellspacing=0>
							
								

<tr>
								

	<td bgcolor="#999999" >
								

			<script type="text/javascript">
<!--
var ver='4.0.3';
var m1=new Object;
m1.name='m1';
m1.fnm='menu_m1';
if(!window.lastm||window.lastm<1)lastm=1;
m1.v17=null;
m1.v17Timeout='';
var maxZ=1000;
m1.v18;
m1.targetFrame;
var docLoaded=false;
m1.bIncBorder=true;
m1.v29=null;
m1.v29Str='';
m1.v55=50;
m1.scrollStep=10;
m1.fadingSteps=8;
m1.itemOverDelay=0;
m1.transTLO=0;
m1.fixSB=1;
m1.v62=0;
m1.v21="./menu";
m1.maxlev=3;
m1.v22=0;
m1.sepH=10;
m1.bHlNL=1;
m1.showA=1;
m1.bVarWidth=0;
m1.bShowDel=0;
m1.scrDel=0;
m1.v23=150;
m1.levelOffset=20;
m1.bord=1;
m1.vertSpace=3;
m1.sep=1;
m1.v19=false;
m1.bkv=0;
m1.rev=0;
m1.shs=0;
m1.popu=1;
m1.xOff=0;
m1.yOff=0;
m1.xSOff=0;
m1.ySOff=2;
m1.v20=false;
m1.cntFrame="";
m1.menuFrame="";
m1.v24="";
m1.mout=false;
m1.iconSize=8;
m1.closeDelay=1000;
m1.tlmOrigBg="#999999";
m1.tlmOrigCol="White";
m1.v25=false;
m1.v52=false;
m1.v60 = 0;
m1.v11=false;
m1.v10=0;
m1.ppLeftPad = 5;
m1.v54 = 0;
m1.v01=2;
m1.tlmHlBg="#FC9A2A";
m1.tlmHlCol="White";
m1.borderCol="White";
m1.menuHorizontal=true;
m1.scrollHeight=6;

m1.attr = new Array 

("12px",false,false,"White","#999999","White","Tahoma,Ari

al","#FC9A2A","White","#999999") ;

m1mn1 = new Array
(
"View 

all","listNewslettersubscribers.asp?idAdmin=1&adminName=a

dmin1",0,"",""
,"View by 

list","subscribersPerlist.asp?idAdmin=1&adminName=admin1"

,0,"",""
,"Search","",1,"",""
,"CSV 

export","csvSubscribersExport.asp?idAdmin=1&adminName=adm

in1",0,"",""
,"Custom messages","",1,"",""
,"Sign-up forms","",1,"",""
,"Utilities","",1,"",""
)

m1mn1_3 = new Array
(
"Advanced 

(Filter+)","createSendFilter.asp?idAdmin=1&adminName=admi

n1",0,"",""
,"Simple","findSubscriberExec.asp?idAdmin=1&adminName=adm

in1",0,"",""
)

m1mn1_5 = new Array
(
"Welcome & goodbye messages","",1,"",""
,"Newsletter for new 

subscribers","sendToNew.asp?idAdmin=1&adminName=admin1",0

,"",""
)

m1mn1_5_1 = new Array
(
"in 

Html","editMessages.asp?idAdmin=1&adminName=admin1",0,"",

""
,"in 

Text","editMessagesText.asp?idAdmin=1&adminName=admin1",0

,"",""
)

m1mn1_6 = new Array
(
"Create custom 

forms","createSignUpForm.asp?idAdmin=1&adminName=admin1",

0,"",""
,"View ready 

forms","../forms/home.asp?idAdmin=1&adminName=admin1",0,"

_blank",""
)

m1mn1_7 = new Array
(
"Change status to","",1,"",""
,"Confirm","",1,"",""
,"View 

non-assigned","listNonAssignedSubscribers.asp?idAdmin=1&a

dminName=admin1v",0,"",""
)

m1mn1_7_1 = new Array
(
"Html","makeAllHtmlText.asp?h=-1",0,"",""
,"Text","makeAllHtmlText.asp?h=0",0,"",""
)

m1mn1_7_2 = new Array
(
"Confirm all","makeAllConfirmed.asp",0,"",""
,"Send confirmation 

request","sendConfirmRequest.asp?idAdmin=1&adminName=admi

n1",0,"",""
,"Delete 

un-confirmed","deleteNonConfirmedByDate.asp?idAdmin=1&adm

inName=admin1",0,"",""
)

m1mn2 = new Array
(
"View","lists.asp?idAdmin=1&adminName=admin1",0,"",""
,"Create 

new","addNewListForm.asp?idAdmin=1&adminName=admin1",0,""

,""
,"List traffic 

report","listTraffic.asp?idAdmin=1&adminName=admin1",0,""

,""
)

m1mn3 = new Array
(
"Html newsletters","",1,"",""
,"Text newsletters","",1,"",""
)

m1mn3_1 = new Array
(
"View & 

edit","htmlNewsletters.asp?idAdmin=1&adminName=admin1",0,

"",""
,"Create 

new","sendNewsletterForm.asp?idAdmin=1&adminName=admin1",

0,"",""
)

m1mn3_2 = new Array
(
"View & 

edit","textNewsletters.asp?idAdmin=1&adminName=admin1",0,

"",""
,"Create 

new","sendTextNewsletterForm.asp?idAdmin=1&adminName=admi

n1",0,"",""
)

m1mn4 = new Array
(
"New mailing 

(Send+)","quickSendForm.asp?idAdmin=1&adminName=admin1",0

,"",""
,"View all 

mailings","mailLogs.asp?idAdmin=1&adminName=admin1",0,"",

""
,"View completed mailings","mailLogs.asp?f=-1",0,"",""
,"View not-completed mailings","mailLogs.asp?f=0",0,"",""
)

m1mn5 = new Array
(
"Views 

tracking","openRatestats.asp?idAdmin=1&adminName=admin1",

0,"",""
,"Clicks 

tracking","stats.asp?idAdmin=1&adminName=admin1",1,"",""
,"List traffic 

report","listTraffic.asp?idAdmin=1&adminName=admin1",0,""

,""
,"View opt-out 

reasons","listReasons.asp?idAdmin=1&adminName=admin1",0,"

",""
,"Filter+","createSendFilter.asp?idAdmin=1&adminName=admi

n1",0,"",""
)

m1mn5_2 = new Array
(
"Edit tracking 

links","editTrackingLinksForm.asp?idAdmin=1&adminName=adm

in1",0,"",""
)

m1mn6 = new Array
(
"View 

filters","editSendFiltersForm.asp?idAdmin=1&adminName=adm

in1",0,"",""
,"Create 

new","createSendFilter.asp?idAdmin=1&adminName=admin1",0,

"",""
)

m1mn7 = new Array
(
"Configuration & 

settings","settingsModifyForm.asp?idAdmin=1&adminName=adm

in1",0,"",""
,"Forward to a friend","",1,"",""
,"Subscribe a friend","",1,"",""
,"Privacy page","",1,"",""
,"Email component test","",1,"",""
,"Help & 

support","helpSupport.asp?idAdmin=1&adminName=admin1",0,"

",""
)

m1mn7_2 = new Array
(
"See sample 

code","friendForms.asp?idAdmin=1&adminName=admin1",0,"","

"
)

m1mn7_3 = new Array
(
"See sample 

code","friendForms.asp?idAdmin=1&adminName=admin1",0,"","

"
)

m1mn7_4 = new Array
(
"Edit","modifyPrivacyForm.asp?idAdmin=1&adminName=admin1"

,0,"",""
,"Preview","../forms/privacy.asp?idAdmin=1&adminName=admi

n1",0,"_blank",""
)

m1mn7_5 = new Array
(
"Start the 

test","testMail.asp?idAdmin=1&adminName=admin1",0,"",""
)

m1mn8 = new Array
(
"Bounce 

manager","bounceManager.asp?idAdmin=1&adminName=admin1",0

,"",""
,"Scheduler","",1,"",""
)

m1mn8_2 = new Array
(
"View 

entries","schedulerTasks.asp?idAdmin=1&adminName=admin1",

0,"",""
,"Create 

new","schedulerCreateTaskForm.asp?idAdmin=1&adminName=adm

in1",0,"",""
)


absPath="";
if (m1.v19 && !m1.v20)
{
	if 

(window.location.href.lastIndexOf("\\")>window.location.h

ref.lastIndexOf("/")) {sepCh = "\\" ;} else {sepCh = "/" 

;}
	absPath = 

window.location.href.substring(0,window.location.href.las

tIndexOf(sepCh)+1);
}
m1.v02=m1.v23;
document.write("<style 

type='text/css'>\n.m1CL0,.m1CL0:link{text-decoration:none

;width:100%;color:White; 

}\n.m1CL0:visited{color:White}\n.m1mit{padding-left:15px;

padding-right:15px;color:White; font-family:Tahoma,Arial; 

font-size:12px; }\n"+"</"+"style>");
document.write("<scr"+"ipt type='text/javascript' 

src='./menu/menu_dom.js'></"+"script>");
//-->
</script>

<table id="m1mainSXMenu2" cellspacing="1" cellpadding="4" 

 style=";width:">
<tr style="text-align:center">
<td 

onmouseover="chgBg(m1,'m1tlm0',3);exM(m1,'none','',event)

" onmouseout="chgBg(m1,'m1tlm0',0,1)" id="m1tlm0" 

onmousedown="f58('m1tlm0a')" 

style="background-color:#999999;" class="m1mit" ><a 

id="m1tlm0a" class="m1CL0" 

href="menu.asp?idAdmin=1&adminName=admin1" >Home</a></td>
<td 

onmouseover="chgBg(m1,'m1tlm1',3);exM(m1,'m1mn1','m1tlm1'

,event)" 

onmouseout="chgBg(m1,'m1tlm1',0);coM(m1,'m1mn1')" 

id="m1tlm1" style="background-color:#999999;" 

class="m1mit" ><a id="m1tlm1a" class="m1CL0" 

href="javascript:void(0);" >Subscribers<img width="8" 

height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm2',3);exM(m1,'m1mn2','m1tlm2'

,event)" 

onmouseout="chgBg(m1,'m1tlm2',0);coM(m1,'m1mn2')" 

id="m1tlm2" onmousedown="f58('m1tlm2a')" 

style="background-color:#999999;" class="m1mit" ><a 

id="m1tlm2a" class="m1CL0" 

href="lists.asp?idAdmin=1&adminName=admin1"  >Mailing 

lists<img width="8" height="8" 

src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm3',3);exM(m1,'m1mn3','m1tlm3'

,event)" 

onmouseout="chgBg(m1,'m1tlm3',0);coM(m1,'m1mn3')" 

id="m1tlm3" style="background-color:#999999;" 

class="m1mit" ><a id="m1tlm3a" class="m1CL0" 

href="javascript:void(0);" >Newsletters<img width="8" 

height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm4',3);exM(m1,'m1mn4','m1tlm4'

,event)" 

onmouseout="chgBg(m1,'m1tlm4',0);coM(m1,'m1mn4')" 

id="m1tlm4" style="background-color:#999999;" 

class="m1mit" ><a id="m1tlm4a" class="m1CL0" 

href="javascript:void(0);" >Mailing activity<img 

width="8" height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm5',3);exM(m1,'m1mn5','m1tlm5'

,event)" 

onmouseout="chgBg(m1,'m1tlm5',0);coM(m1,'m1mn5')" 

id="m1tlm5" style="background-color:#999999;" 

class="m1mit" ><a id="m1tlm5a" class="m1CL0" 

href="javascript:void(0);" >Reports<img width="8" 

height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm6',3);exM(m1,'m1mn6','m1tlm6'

,event)" 

onmouseout="chgBg(m1,'m1tlm6',0);coM(m1,'m1mn6')" 

id="m1tlm6" style="background-color:#999999;" 

class="m1mit" ><a id="m1tlm6a" class="m1CL0" 

href="javascript:void(0);" >Filter+<img width="8" 

height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm7',3);exM(m1,'m1mn7','m1tlm7'

,event)" 

onmouseout="chgBg(m1,'m1tlm7',0);coM(m1,'m1mn7')" 

id="m1tlm7" onmousedown="f58('m1tlm7a')" 

style="background-color:#999999;" class="m1mit" ><a 

id="m1tlm7a" class="m1CL0" 

href="tools.asp?idAdmin=1&adminName=admin1"  >Tools<img 

width="8" height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>
<td 

onmouseover="chgBg(m1,'m1tlm8',3);exM(m1,'m1mn8','m1tlm8'

,event)" 

onmouseout="chgBg(m1,'m1tlm8',0);coM(m1,'m1mn8')" 

id="m1tlm8" style="background-color:#999999;" 

class="m1mit" ><a id="m1tlm8a" class="m1CL0" 

href="javascript:void(0);" >Extras<img width="8" 

height="8" src="./menu/menu_m1iad.gif" 

style="vertical-align:middle;border-style:none" alt="" 

/></a></td>

</tr>
</table>

								

	</td>
								

	<!--<td bgcolor="#CCCCCC"><a href="help.asp#" 

onclick="window.open(this.href,'window','width=380,height

=590,resizable=yes,scrollbars=yes');return false"><img 

src="./images/helpH.gif" border="0" alt="Help"></a>
								

		<img src=images/cleardot.gif height="1" 

width="5"><a href="logOff.asp"><img src="./images/lo.gif" 

border="0" alt="Log off"></a>
								

	</td>-->
								

</tr>
						
						</table>
					</td>
				</tr>
			
			</table>
		</td>
		
		<td rowspan=3 valign=top 

bgcolor="#CCCCCC" width=15></td>
	</tr>
	<!--Main page row starts-->

	<tr>
		<td>
			<table border="0" cellpadding="5" 

cellspacing="6" width="100%" height=650>
			<tbody valign=top>
				<tr>
					<td 

height=10></td></tr>
				<tr>
					<td>


INSERT INTO wce_linkto (LuniqueID, LUTableName, 

LEntityID, LETableName) VALUES ('0872292480', 

'wce_history','bBCpiahl3Dfc','wce_contact')</br></br>INSE

RT INTO wce_linkto (LuniqueID, LUTableName, LEntityID, 

LETableName) VALUES ('0872292480', 

'wce_history','psi1a5c31uc2wmzd','wce_contact')</br></br>

INSERT INTO wce_linkto (LuniqueID, LUTableName, 

LEntityID, LETableName) VALUES ('0872292480', 

'wce_history','qsi1dq625spbj746','wce_contact')</br></br>

INSERT INTO wce_linkto (LuniqueID, LUTableName, 

LEntityID, LETableName) VALUES ('0872292480', 

'wce_history','v4R7carlltYa','wce_contact')</br></br>INSE

RT INTO wce_linkto (LuniqueID, LUTableName, LEntityID, 

LETableName) VALUES ('0872292480', 

'wce_history','q9q1ubo24u5gfc3h','wce_contact')</br></br>
 
You need to move this
[red]linktoLuniqueID = right(year(now),2)&month(now)&day(now)&hour(now)&minute(now)&second(now)[/red]
inside the loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top