473,563 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop runs indefinite times

vikas251074
198 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <title>IP Management - Saving master data.</title>
  7. </head>
  8. <%
  9. dim conn 
  10. dim rs 
  11. dim i
  12. set conn = server.createobject("ADODB.Connection")
  13. conn.open = "Provider=MSDAORA.1; dsn=ipis; User ID=ipis; Password=ipis; data source=isap2000;Persist Security Info=True"
  14. set rs = server.createobject("ADODB.Recordset")
  15. v_vlan_name = trim(request.form("vlan_name"))
  16. v_first_ip = trim(request.form("first_ip"))
  17. v_last_ip = trim(request.form("last_ip"))
  18. v_subnet_mask = trim(request.form("subnet_mask"))
  19. v_router = request.form("router")
  20. v_network_switch = request.form("network_switch")
  21. v_camera = request.form("camera")
  22. v_printer = request.form("printer")
  23. v_server = request.form("server")
  24. v_pc = request.form("pc")
  25. 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& ")")
  26. if v_router > 0 then
  27.   i=1
  28.   j=1
  29.   temp_ip = v_first_ip
  30.   while i <= v_router
  31.     v_ip_address = temp_ip
  32.     set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','R',"&i&",'"&v_ip_address&"')")
  33.     i = i + 1
  34.     j = j + 1
  35.     temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
  36.   wend
  37. end if
  38. if v_network_switch > 0 then
  39.   i=1
  40.   do while i <= v_network_switch
  41.     v_ip_address = temp_ip
  42.     set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','SW',"&i&",'"&v_ip_address&"')")
  43.     i = i + 1
  44.     j = j + 1
  45.     temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
  46.   loop
  47. end if
  48. if v_camera > 0 then
  49.   i=1
  50.   do while i <= v_camera
  51.     v_ip_address = temp_ip
  52.     set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','C',"&i&",'"&v_ip_address&"')")
  53.     i = i + 1
  54.     j = j + 1
  55.     temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
  56.   loop
  57. end if
  58. if v_printer > 0 then
  59.   i=1
  60.   do while i <= v_printer
  61.     v_ip_address = temp_ip
  62.     set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','P',"&i&",'"&v_ip_address&"')")
  63.     i = i + 1
  64.     j = j + 1
  65.     temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
  66.   loop
  67. end if
  68. if v_server > 0 then
  69.   i=1
  70.   do while i <= v_server
  71.     v_ip_address = temp_ip
  72.     set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','S',"&i&",'"&v_ip_address&"')")
  73.     i = i + 1
  74.     j = j + 1
  75.     temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
  76.   loop
  77. end if
  78. if v_pc > 0 then
  79.   i=1
  80.   do while i <= v_pc
  81.     v_ip_address = temp_ip
  82.     set rs=conn.execute("insert into vlan_detail(vlan_name, item, seq_no, ip_address) values('"&v_vlan_name&"','PC',"&i&",'"&v_ip_address&"')")
  83.     i = i + 1
  84.     j = j + 1
  85.     temp_ip = mid(temp_ip,1,instrrev(temp_ip,"."))+cstr(j)
  86.   loop
  87. end if
  88. %>
  89. <body>
  90. </body>
  91. </html>
  92.  
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
Jun 9 '08 #1
4 1811
idsanjeev
241 New Member
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.25 5.0"
v_router = 5
v_network_switc h = 5
v_camera =5
v_printer =5
v_server = 5
v_pc = 230

Regards
Jha
Jun 9 '08 #2
vikas251074
198 New Member
I used first form to input data and then called next form by <form action="filenam e" 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.
Expand|Select|Wrap|Line Numbers
  1. v_vlan_name = "VLAN1"
  2. v_first_ip = "10.66.128.1"
  3. v_last_ip = "10.66.128.255"
  4. v_subnet_mask = "255.255.255.0"
  5. v_router = 5
  6. v_network_switch = 5
  7. v_camera = 5
  8. v_printer = 5
  9. v_server = 5
  10. 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
Jun 9 '08 #3
vikas251074
198 New Member
This problem is solved by adding cint() in line no. 19 - 24.

Thanks and regards,
Vikas
Jun 10 '08 #4
idsanjeev
241 New Member
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
Jun 11 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

21
18680
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 nanosleep(), depending on platform }
14
2453
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 far with a loop in a form. Basically, I have key sums Current savings Current Salary Current deposit amount
13
2176
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 menu is displayed, the input is registered and the loop runs. On the second (and following) runs the menu is printed twice. I am sure there is...
22
2198
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;
102
4479
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 spend twice the time to complete. If the loop is included it takes about 7.48 seconds to complete, but when removed it takes about 11.48 seconds. ...
3
3052
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. http://groups.google.com/group/comp.lang.c++/browse_frm/thread/c6a7c9c950fc2b81/ff321b7f89181798?q=indefinite+number+of+arguments&rnum=1 But I'm wonder with the help of boost, can this take be done? Thanks,
19
2910
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;
70
3465
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 sample: ------ while(1=1) { printf("oi"); ch=getchar(); if (ch=='q') break; }
2
19297
ADezii
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 iterates a specified number of times, requires you to also implement or decrement some sort of Loop Counter, while a For...Next Loop does that work for you....
0
7665
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7950
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.