By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

Problem while using "CInt"

Vini171285
P: 60
Hi,
Here in this code we have used CInt before Session,If we wont use CInt the code doesn't work in the intended way....and using CInt sometimes gives error..It works for 1 day & the other day shows error...What & why is this problem?? Is there any alternative for "CInt" or we ll hv to include any file..
Please Help !

Expand|Select|Wrap|Line Numbers
  1. <%@ language=VBScript%>
  2. <% option explicit %>
  3. <!--#include virtual="/adovbs.inc"-->
  4. <HTML>
  5. <BODY>
  6. <form method=post action="z2.asp">
  7. Name:<input type=text name=name value=<%=Session("name")%>><BR>
  8. Password:<input type=password name=pwd>
  9. <BR>
  10. <%
  11. Response.Write CInt(Session("age"))
  12. %><BR>
  13. Age:<select name=age>
  14. <%
  15.     Dim objConn
  16.     Set objConn=Server.CreateObject("ADODB.Connection")
  17.     objConn.ConnectionString="DSN=Info.dsn;uid=vini;pwd=vini"
  18.     objConn.Open
  19.  
  20.     Dim sql
  21.     sql="SELECT * FROM age"
  22.  
  23.     Dim objRS
  24.     Set objRS=Server.CreateObject("ADODB.Recordset")
  25.     objRS.Open sql,objConn
  26.  
  27.     Dim i
  28.     i=CInt(Session("age"))
  29.  
  30.     Do while not objRS.EOF
  31.         If i=CInt(objRS("num")) Then
  32.             Response.Write "<option value=" & objRS("num")& " selected>"
  33.             Response.Write objRS("age") & "</option>"
  34.         Else
  35.             Response.Write "<option value=" & objRS("num") & ">"
  36.             Response.Write objRS("age") & "</option>"
  37.         End If
  38.         objRS.MoveNext
  39.     Loop
  40.  
  41.     objRS.Close
  42.     Set objRS=Nothing
  43.  
  44.     objConn.Close
  45.     Set objConn=Nothing
  46. %>
  47. </select>
  48.  
  49. <input type=submit>
  50. </form>
  51. </BODY>
  52. </HTML>
Apr 29 '08 #1
Share this Question
Share on Google+
5 Replies


DrBunchman
Expert 100+
P: 979
Using CInt casts your variable to an integer but it will error if the value of the variable doesn't contain an integer value e.g it contains a char. Are you certain that objRS("num") is always an integer value?

What are the errors that are sometimes occuring?

Dr B
Apr 29 '08 #2

Vini171285
P: 60
hi..
When we use CInt, error is type mismatch..
but when we remove it ,the value of list box is not stored..it is lost..
and after sometime if we again put CInt,it works properly..
and value is retained..
So,we are just putting CInt for all listboxes one day...
and next day we are removing CInt so that our program shd run.....

and also,Sometime we get error such as "Operation Timed Out"...
This is related to oracle..
After this error occurs, our programs doesn't run for near about 2 days and after that it starts working automatically..
we don't know wat the problem is...
Do u think it is related to hardware or may be some problem with our code??

Thanks
Apr 29 '08 #3

DrBunchman
Expert 100+
P: 979
I doubt it's hardware related.

Is the data you are querying static? If not and your data is changing day to day and the performance of your web page is also changing day to day it would suggest that the data is the cause of the problem.

Next time you get the type mismatch error comment out the bit that's causing the problem and stick a response.write in to see what the value actually is.

Also, is your query so big and returning so many results that you'd expect it to cause a time out?
Apr 29 '08 #4

Vini171285
P: 60
In our project ther are 4 web pages, there are near about 30-35 list boxes and may be 25-30 text boxes per page..
and all list boxes are filled from database and data is static..
and when the time out error occurs,we are not even able to open our database.
Thanx
Apr 29 '08 #5

DrBunchman
Expert 100+
P: 979
If the data is static then the data can't be the problem. Perhaps the problem is the session variable not being correctly retained?

Remember that when an asp page errors it ends the current session. Every time you have a timeout it will destroy the session value which may be part of the problem.

Can you test for the value of that the next time you get a type mis-match?
Apr 29 '08 #6

Post your reply

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