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. - <!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>
-
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
4 1807
hello vikas
after assining value in your variables thats works fine so pleas check your value passed
i am testing your code with this value
v_vlan_name = "vlan1"
v_first_ip = "10.66.128.1"
v_last_ip = "10.66.128.255"
v_subnet_mask = "255.255.255.0"
v_router = 5
v_network_switch = 5
v_camera =5
v_printer =5
v_server = 5
v_pc = 230
Regards
Jha
I used first form to input data and then called next form by <form action="filename" method="post">
I think problem lies in line no. 30 - 36 where the loop runs. Here the loop runs indefinite times. And data is stored like this in table VLAN_DETAIL.
vlan1, R, 1, 10.66.128.1
vlan1, R, 2, 10.66.128.2
vlan1, R, 3, 10.66.128.3
vlan1, R, 4, 10.66.128.4
vlan1, R, 5, 10.66.128.5
vlan1, R, 6, 10.66.128.6
---------------
--------------
vlan1, R, 999, 10.66.128.999
But when i modified line no.25 - 34 as below, then programe works fine. - v_vlan_name = "VLAN1"
-
v_first_ip = "10.66.128.1"
-
v_last_ip = "10.66.128.255"
-
v_subnet_mask = "255.255.255.0"
-
v_router = 5
-
v_network_switch = 5
-
v_camera = 5
-
v_printer = 5
-
v_server = 5
-
v_pc = 230
Then data inserted is as follows -
vlan1, R, 1, 10.66.128.1
vlan1, R, 2, 10.66.128.2
vlan1, R, 3, 10.66.128.3
vlan1, R, 4, 10.66.128.4
vlan1, R, 5, 10.66.128.5
vlan1, S, 1, 10.66.128.6
vlan1, S, 2, 10.66.128.7
---------
vlan1, S, 5, 10.66.128.10
vlan1, C, 1, 10.66.128.11
------
------
and so on.
Please tell me what is wrong with this.
Thanks and regards,
Vikas
This problem is solved by adding cint() in line no. 19 - 24.
Thanks and regards,
Vikas
This problem is solved by adding cint() in line no. 19 - 24.
Thanks and regards,
Vikas
Glade you got it working now
nice porgramming
Regards
Jha
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alo Sarv |
last post by:
Hi
From what I have understood from various posts in this newsgroup, writing event
loops pretty much comes down to this:
while (true) {
handleEvents();
sleep(1); // or _sleep() or...
|
by: Crimsonwingz |
last post by:
Need to calculate a sum based on a number of factors over a period of
years. I can use formula ^x for some of it, but need totals to carry
over in the sum and have only been able to do this thus...
|
by: Redduck |
last post by:
Hello everyone. I am frustrated, I have written the simple program
below for a class and I am having problems with the DO-WHILE loop. On
the first run through the loop, everything works well, the...
|
by: Jan Richter |
last post by:
Hi there,
the Code below shows DJBs own implementation of strlen (str_len):
unsigned int str_len(char *s)
{
register char *t;
t = s;
for (;;) {
if (!*t) return t - s; ++t;
|
by: tom fredriksen |
last post by:
Hi
I was doing a simple test of the speed of a "maths" operation and when I
tested it I found that removing the loop that initialises the data array
for the operation caused the whole program to...
| |
by: PengYu.UT |
last post by:
I quickly searched the group.
Like the post said, it is not possible to specify indefinite number of
arguments.
...
|
by: vamshi |
last post by:
Hi all,
This is a question about the efficiency of the code.
a :-
int i;
for( i = 0; i < 20; i++ )
printf("%d",i);
b:-
int i = 10;
|
by: hstagni |
last post by:
When i read a key using getchar() inside a loop, the program stops and
wait for a key to be pressed. I actually want the program to continue
its execution until a key is pressed. Look at this...
|
by: ADezii |
last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |