473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem while using "CInt"

Vini171285
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
5 2462
DrBunchman
979 Expert 512MB
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
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
979 Expert 512MB
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
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
979 Expert 512MB
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

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

Similar topics

1
by: Andreas Klemt | last post by:
Hello, I have this session("myNumber") = 888 Dim intNumber As Integer a) intNumber = session("myNumber") b) intNumber = Convert.ToInt32(session("myNumber"))
2
by: me2 | last post by:
greetings im having problem with adding to values in as the sample code : <% = Request("Travelling") + Request("Photographs") % Let say travelling is 3 and photographs is 4, i get the answer...
18
by: Atara | last post by:
In my apllication I use the following code: '-- My Code: Public Shared Function strDate2Date(ByVal strDate As String) As System.DateTime Dim isOk As Boolean = False If (strDate Is Nothing)...
1
by: melda | last post by:
I am a real beginnner in ASP. Due to increasing demands on dynamic website, I've been working on ASP website now. I use a ready to use CMS program and right now I've been trying to combine a calendar...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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 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.