How to convery from string to integer for sending

Results 1 to 4 of 4

Thread: How to convery from string to integer for sending

  1. #1
    Join Date
    Dec 1969
    Posts
    53

    Default How to convery from string to integer for sending

    &nbsp;<BR>hi..hope u can help<BR><BR>i need to be able to do the following<BR>1) retrieve input value from a prompt dialog in javascript, i get a string rite,like this<BR><BR>var id;<BR>id=prompt(&#039Enter the Author Id:&#039, &#039&#039);<BR><BR> 2) Now i have to sent this string to another page <BR>like this<BR><BR> window.location.href="author.asp?identity=id";<BR> <BR>3) in author.asp I need to retrieve this value<BR>in vbscript like this<BR><BR>Dim idfield<BR>idfield = Request.QueryString("identity")<BR><BR>4) the problem comes when i have to use idfield as a search criteria in an sql query where it<BR>retrieves a record for a particular id(stored as an integer in the database) I have this integer string<BR>conversion problem..<BR><BR><BR>how do i convert a string to an integer so that i can properly transfer it to another file and use it in a query<BR><BR><BR>thanks

  2. #2
    Nathan Pond Guest

    Default RE: How to convery from string to integer for send

    In your vbscript, do this:<BR><BR>idField = CInt(idField)

  3. #3
    John Weeflaar Guest

    Default RE: How to convery from string to integer for send

    You don&#039t have to convert a string to an integer <BR>when you pass a variable between pages (a variant variable<BR>can accept any data type).<BR>But, when dealing with the database, such as creating a query,<BR>etc, then it&#039s time to inform the database, what type this<BR>variable is (otherwise an error occurs).<BR>in author.asp, after the line:<BR>idfield = Request.QueryString("identity")<BR>You can write an SQL:<BR><BR>SQL = "SELECT ... WHERE id =" & idfield<BR>(assuming id is a field of type integer in your table).<BR>By concatenating idfield like that, you tell the database that idfield contains an integer value.<BR><BR>Cheers,<BR><BR>John

  4. #4
    John Weeflaar Guest

    Default RE: How to convery from string to integer for send

    Sorry Nathan, I didn&#039t know you&#039ve answered this<BR>(my page hadn&#039t been refreshed when i answered this).<BR><BR>Thanks,<BR><BR>John


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •