convert a string...

Results 1 to 2 of 2

Thread: convert a string...

  1. #1
    Join Date
    Dec 1969

    Default convert a string...

    Hello, I am using the GET method to send a variable with an URL. This variable is a employeenumber. On my new page I use the following code: <BR><BR>vVar = Request.QueryString("var")<BR><BR>In my Access database the field "AnstNr" is a number. I thought that I could use: <BR>vVar = CInt(vVar)<BR>and then write the SQL like this:<BR>SQL = "SELECT * FROM person WHERE AnstNr = &#039;" & vVar & "&#039;"<BR>but the browser says that it is a mixture of types in the SQL. Is there a possibility to use something else than QueryString so that the datatype becomes a number instead of a string.<BR>/Lotta<BR>

  2. #2
    Join Date
    Dec 1969

    Default It doesn't matter... you get the data, it will still be in the same datatype regardless.<BR><BR>Cint() does convert strings into numbers but only if its numeric data, look at the IsNumeric() which checks for this before sending it to your conversion function.<BR><BR>As for your problem, presumably the AnstNr field in your DB is a numeric field, your sending it a string because you have included single quote&#039;s around it.<BR><BR>Try "SELECT * FROM person WHERE AnstNr = " & vVar<BR><BR>Matt<BR>

Posting Permissions

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