Loop runs indefinite times.
suppose v_router = 5 is entered by user, then following code runs indefinite times i.e. record is inserted indefinite times though each have different i and v_ip_address.
Line no. 30 - 36 runs indefinite times. It does not comes out of loop even when value of i becomes 6. i.e. the condition [while i<= v_router] should become false, but not.
Please tell me what is wrong with this code.
Thanks and regards,
Vikas
suppose v_router = 5 is entered by user, then following code runs indefinite times i.e. record is inserted indefinite times though each have different i and v_ip_address.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>IP Management - Saving master data.</title>
</head>
<%
dim conn
dim rs
dim i
set conn = server.createobject("ADODB.Connection")
conn.open = "Provider=MSDAORA.1; dsn=ipis; User ID=ipis; Password=ipis; data source=isap2000;Persist Security Info=True"
set rs = server.createobject("ADODB.Recordset")
v_vlan_name = trim(request.form("vlan_name"))
v_first_ip = trim(request.form("first_ip"))
v_last_ip = trim(request.form("last_ip"))
v_subnet_mask = trim(request.form("subnet_mask"))
v_router = request.form("router")
v_network_switch = request.form("network_switch")
v_camera = request.form("camera")
v_printer = request.form("printer")
v_server = request.form("server")
v_pc = request.form("pc")
set rs = conn.execute("insert into vlan_master(vlan_name, first_ip, last_ip, subnet_mask, router, network_switch, camera, printer, server, pc)values('"&v_vlan_name&"','"&v_first_ip&"','"&v_last_ip&"','"&v_subnet_mask&"',"&v_router&","&v_network_switch&","&v_camera&","&v_printer&","&v_server&","&v_pc& ")")
if v_router > 0 then
i=1
j=1
temp_ip = v_first_ip
while i <= v_router
v_ip_address = temp_ip
set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','R',"&i&",'"&v_ip_address&"')")
i = i + 1
j = j + 1
temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
wend
end if
if v_network_switch > 0 then
i=1
do while i <= v_network_switch
v_ip_address = temp_ip
set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','SW',"&i&",'"&v_ip_address&"')")
i = i + 1
j = j + 1
temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
loop
end if
if v_camera > 0 then
i=1
do while i <= v_camera
v_ip_address = temp_ip
set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','C',"&i&",'"&v_ip_address&"')")
i = i + 1
j = j + 1
temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
loop
end if
if v_printer > 0 then
i=1
do while i <= v_printer
v_ip_address = temp_ip
set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','P',"&i&",'"&v_ip_address&"')")
i = i + 1
j = j + 1
temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
loop
end if
if v_server > 0 then
i=1
do while i <= v_server
v_ip_address = temp_ip
set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','S',"&i&",'"&v_ip_address&"')")
i = i + 1
j = j + 1
temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
loop
end if
if v_pc > 0 then
i=1
do while i <= v_pc
v_ip_address = temp_ip
set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','PC',"&i&",'"&v_ip_address&"')")
i = i + 1
j = j + 1
temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
loop
end if
%>
<body>
</body>
</html>
Please tell me what is wrong with this code.
Thanks and regards,
Vikas
Comment