Professional Web Applications Themes

comparing 2 "bigint" fields - ASP Database

Hi peeps Finally upsized my database, and I've got an odd error... The error is simply "Type Mismatch" and is occuring when I try to compare 2 "bigint" datatypes. Like this... if table1("field") = table2("field") then Both fields are set to BigInt in SQL Server, and I can't find anything on the net that would cause this. Any ideas? Cheers Dan...

  1. #1

    Default comparing 2 "bigint" fields

    Hi peeps

    Finally upsized my database, and I've got an odd error...

    The error is simply "Type Mismatch" and is occuring when I try to compare 2
    "bigint" datatypes. Like this...

    if table1("field") = table2("field") then

    Both fields are set to BigInt in SQL Server, and I can't find anything on
    the net that would cause this. Any ideas?

    Cheers


    Dan
    Dan Guest

  2. #2

    Default Re: comparing 2 "bigint" fields

    Dan Nash wrote: 

    Debugging 101

    Response.Write """" & table1("field") & """<BR>"
    Response.Write """" & table2("field") & """<BR>"

    And if that causes the Type Mismatch, try explicitly specifying the Value
    property:
    Response.Write """" & table1("field").Value & """<BR>"

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  3. #3

    Default Re: comparing 2 "bigint" fields

    Hi Bob

    Tried the debug, and it works fine, I can get table(field) no problems. Any
    ideas why the compare isnt working though?

    Cheers


    Dan

    "Bob Barrows [MVP]" wrote:
     
    >
    > Debugging 101
    >
    > Response.Write """" & table1("field") & """<BR>"
    > Response.Write """" & table2("field") & """<BR>"
    >
    > And if that causes the Type Mismatch, try explicitly specifying the Value
    > property:
    > Response.Write """" & table1("field").Value & """<BR>"
    >
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    >[/ref]
    Dan Guest

  4. #4

    Default Re: comparing 2 "bigint" fields

    Nope. Try doing an explicit conversion. I think CDbl should work with data
    of this size...

    if CDbl(table1("field").value) = CDBl(table2("field").value) then

    Bob Barrows

    Dan Nash wrote: 

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Guest

  5. #5

    Default Re: comparing 2 "bigint" fields

    Have you considered performing the comparison in SQL Server?

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Dan Nash" <co.uk> wrote in message
    news:com... 



    Aaron Guest

  6. #6

    Default Re: comparing 2 "bigint" fields

    Hi Bob

    The explicit conversion using CDbl worked great - thanks.

    I was just wondering though, is that the best way to do things? Will it
    cause me any problems further down the line, if I go through my code adding
    lots of CDbl() commands?

    I'm using bigint as an ID field (needs to be bigger than int). Isn't there a
    unique identifier field, and if so how would I store that as a reference,
    would it have to be as a text field?

    Basically, is bigint and CDbl safe to use throughout? Obviously I'm gonna
    have to edit lots of code either way!

    Cheers


    Dan

    "Bob Barrows [MVP]" wrote:
     
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >[/ref]
    Dan Guest

  7. #7

    Default Re: comparing 2 "bigint" fields

    As both I and other responders have suggested, if it is possible to do the
    comparison in your queries, that would be the best route.

    As for whether or not CDbl is safe to use for all possible values of a
    bigint column, I can't amswer that without looking at online help,. So I
    suggest you take this opportunity to do so: look in SQL Books Online to find
    out the maximum value a bigint column can hold. Then look in the vbscript
    doentation ( http://tinyurl.com/7rk6 ) to see the biggest value a Double
    variable can hold. You will have your answer.

    I do not suggest using char columns for this as you will get string
    comparisons instead of numeric (unless you pad the numbers with leading
    zeroes)

    Bob Barrows

    Dan Nash wrote: 
    >>
    >> --
    >> Microsoft MVP -- ASP/ASP.NET
    >> Please reply to the newsgroup. The email account listed in my From
    >> header is my spam trap, so I don't check it very often. You will get
    >> a quicker response by posting to the newsgroup.[/ref][/ref]

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

Similar Threads

  1. Update art "under" my form fields?
    By Creephead@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 4
    Last Post: April 29th, 08:22 PM
  2. Replies: 1
    Last Post: April 24th, 01:27 PM
  3. CFINPUT type="radio" w/ "value" requires "label"
    By Iceborer in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 21st, 06:16 PM
  4. Replies: 2
    Last Post: September 15th, 04:35 AM
  5. "Start" "Program" "Menu" list is empty
    By Pete in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 10th, 10:42 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