comparing 2 "bigint" fields
comparing 2 "bigint" fields
am 12.10.2004 10:57:03 von dan
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
Re: comparing 2 "bigint" fields
am 12.10.2004 12:49:06 von reb01501
Dan Nash wrote:
> 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?
>
Debugging 101
Response.Write """" & table1("field") & """
"
Response.Write """" & table2("field") & """
"
And if that causes the Type Mismatch, try explicitly specifying the Value
property:
Response.Write """" & table1("field").Value & """
"
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"
Re: comparing 2 "bigint" fields
am 12.10.2004 14:35:04 von dan
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:
> Dan Nash wrote:
> > 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?
> >
>
> Debugging 101
>
> Response.Write """" & table1("field") & """
"
> Response.Write """" & table2("field") & """
"
>
> And if that causes the Type Mismatch, try explicitly specifying the Value
> property:
> Response.Write """" & table1("field").Value & """
"
>
> 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"
>
>
>
Re: comparing 2 "bigint" fields
am 12.10.2004 14:41:59 von reb01501
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:
> Hi Bob
>
> Tried the debug, and it works fine, I can get table(field) no
> problems. Any ideas why the compare isnt working though?
>
--
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.
Re: comparing 2 "bigint" fields
am 12.10.2004 15:50:30 von ten.xoc
Have you considered performing the comparison in SQL Server?
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Dan Nash" wrote in message
news:2F3B849C-4057-4CB1-A0B4-E349EB5A0B85@microsoft.com...
> 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
Re: comparing 2 "bigint" fields
am 13.10.2004 12:03:07 von dan
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:
> 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:
> > Hi Bob
> >
> > Tried the debug, and it works fine, I can get table(field) no
> > problems. Any ideas why the compare isnt working though?
> >
>
> --
> 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.
>
>
>
Re: comparing 2 "bigint" fields
am 13.10.2004 13:09:34 von reb01501
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
documentation ( 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:
> 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:
>
>> 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:
>>> Hi Bob
>>>
>>> Tried the debug, and it works fine, I can get table(field) no
>>> problems. Any ideas why the compare isnt working though?
>>>
>>
>> --
>> 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.
--
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"