Professional Web Applications Themes

data type mismatch in comparison - ASP Database

Hi, i have a sql query that returns date parts from a specific date. looks something like: select datepart( d, sampledate) as "myday" , datepart( m, sampledate) as "mymonth" when this is inserted into my asp page, i store the returned values in cookies: Response.Cookies("MyDay") = rs("myday") Response.Cookies("MyMonth") = rs("mymonth") where rs is the recordset containing the query results. now, my problem is the following: in a later page, i have a counter that is initialized like this: <% counter = 1 %> then i have a comparison on this counter: <% if counter = Request.Cookies("MyDay") then ... %> this ...

  1. #1

    Default data type mismatch in comparison

    Hi,

    i have a sql query that returns date parts from a specific date. looks
    something like:

    select datepart( d, sampledate) as "myday"
    , datepart( m, sampledate) as "mymonth"

    when this is inserted into my asp page, i store the returned values in
    cookies:

    Response.Cookies("MyDay") = rs("myday")
    Response.Cookies("MyMonth") = rs("mymonth")

    where rs is the recordset containing the query results.

    now, my problem is the following: in a later page, i have a counter
    that is initialized like this:

    <% counter = 1 %>

    then i have a comparison on this counter:

    <% if counter = Request.Cookies("MyDay") then ... %>

    this doesn't want to work even though i can clearly see that both
    values are equal at some point in the counter loop. the code runs
    without error, but there never seems to be a case where the if turns
    true. my guess is that this is a type mismatch problem where one of
    the two variables is not an integer.

    i even changed the sql query to do:

    select cast(datepart(d, sampledate) as int) as "myday"
    , ...

    still never equates.

    thanks in advance.
    Adnan Guest

  2. #2

    Default Re: data type mismatch in comparison

    Request.Cookies("MyDay") is a string
    counter is an integer

    try

    if counter = CLng(Request.Cookies("MyDay") )

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "Adnan" <com> wrote in message
    news:google.com... 


    Mark Guest

  3. #3

    Default Re: data type mismatch in comparison

    Try....
    <% if CInt(counter) = CInt(Request.Cookies("MyDay")) then ... %>

    Bob Lehmann

    "Adnan" <com> wrote in message
    news:google.com... 


    Bob Guest

Similar Threads

  1. Access data type mismatch for empty form field
    By createmedia in forum Coldfusion Database Access
    Replies: 5
    Last Post: January 27th, 05:24 PM
  2. data type mismatch error...
    By P_Roberts in forum Coldfusion Database Access
    Replies: 3
    Last Post: November 30th, 04:27 PM
  3. Data type mismatch in criteria expression
    By Captain Ru in forum Coldfusion Database Access
    Replies: 3
    Last Post: July 21st, 05:24 PM
  4. Data type mismatch error assistance please
    By Me in forum ASP Database
    Replies: 6
    Last Post: August 14th, 08:01 PM
  5. Type Mismatch again
    By Miguel Orrego in forum ASP Database
    Replies: 3
    Last Post: July 5th, 06:26 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139