Ask a Question related to ASP, Design and Development.
-
Bob Barrows #1
Re: Confused with the type mismatch error
I tried your simple example and got no type mismatch. I even modified it so
that I was comparing a string to a number and got no type mismatch (it
returns "Not Equal", but that's to be expected when comparing a string to a
number):
dim a, b
a = "123456"
b = a
a = clng(123456)
if a <> b Then
Response.Write "Not equal"
else
Response.Write "Equal"
end if
I cannot venture a guess as to the cause of your mismatch: perhaps you need
to initialize the PreviousOne variable with a value before starting the
loop.
I question why you think being forced to explicitly cast your variables
using CStr is a "bad" thing ... I know you're not saying it's "bad": you're
simply asking why you have to do it in this case. My suggestion would be to
make it a habit: something you do more often than not, instead of only when
you have to.
Bob Barrows
cschang wrote:> Why a variable assigned as '123456' can be mismatched with another
> variable also assign as '123456' in the following example
> dim a, b
> a = '123456'
> b = a
> a = '123456'
> if a <> b Then
> ....
>
> ASP engine return an error " Type mismatch" for a <> b. I had to
> apply Cstr() to both a and b to compare, otherwise it always generates
> the same error, even only the Cstr() on one side of the comparison.
>
> The part of the real codes of my page
>
> Dim previousOne, rowControl
> rowControl = 0
>
> while not rs.EOF and rowControl < rs.PageSize
> If Not isEmpty(previousOne) Then
> If Cstr(previousOne) <> Cstr(rs(1)) Then
> Response.Write ...
> End If
> end If
> Response.Write ...
> ..
> previousOne = rs(1)
> rs.MoveNext
> rowControl = rowControl + 1
> Wend
>
> ' rs is the recordSet return from Oracle procdure. The specific
> record is defined as varchar in database.
>
> CS
Bob Barrows Guest
-
Type mismatch error
This query works fine on a live server using an MSSQL database: <cfquery name="qIndex" datasource="#appDSN#" username="shampoo"... -
data type mismatch error...
HI guys, getting pretty stressed with this haha! it's probably something simple...right I have this registration form that does multiple checks... -
0x800A000D - Type Mismatch Error
I am not sure what is goint on. Here's my code inWeekStart = "11" inWeekEnd = "14" Compyear = "2003" Dim rsSQL, strSQL, cmSQL dim... -
Type mismatch Session error
You'll need to post a snippet of relevant code. Ray at work "TD" <TurboDuster@noyahoospam.com> wrote in message... -
Long Raw Type Mismatch error
I'm new to using long raw fields with ASP. I know it would be easier to leave the files on the file system, but the client wants them in the... -
Ray at #2
Re: Confused with the type mismatch error
Perhaps this is another one of those situations where the value from the
recordset is null.
<%
Dim x
x = null
y = null
If x = y Then
response.write "Yes, null = null."
Else
response.write "No, null <> null."
End If
response.write "<br>"
x = x & ""
y = y & ""
If x = y Then
response.write "Yes, null+"""" = null+""""."
Else
response.write "No, null+"""" <> null+""""."
End If
%>
Ray at home
"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:OifORfNXDHA.2576@TK2MSFTNGP09.phx.gbl...so> I tried your simple example and got no type mismatch. I even modified ita> that I was comparing a string to a number and got no type mismatch (it
> returns "Not Equal", but that's to be expected when comparing a string to> number):
>> >
> > ASP engine return an error " Type mismatch" for a <> b. I had to
> > apply Cstr() to both a and b to compare, otherwise it always generates
> > the same error, even only the Cstr() on one side of the comparison.
Ray at Guest
-
Dave Anderson #3
Re: Confused with the type mismatch error
"cschang" wrote:
Welcome to Default Property Hell. Your problem stems from your mistaken>
> while not rs.EOF and rowControl < rs.PageSize
> If Not isEmpty(previousOne) Then
> If Cstr(previousOne) <> Cstr(rs(1)) Then
> Response.Write ...
> End If
> end If
> Response.Write ...
> ..
> previousOne = rs(1)
> rs.MoveNext
> rowControl = rowControl + 1
> Wend
belief that rs(1) is a value. It is an object with the default property
[Value]. To get around your problem, stop using default properties. The
correct syntax in this case (Assuming an ADODB.Recordset):
previousOne = rs.Fields(1).Value
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Dave Anderson Guest
-
cschang #4
Re: Confused with the type mismatch error
Dave:
You are perfectly right. I tested and found out in my case, all I had to do
was to use previousOne <> rs(1).value and the problem went away. Thank very
much.
C Chang
Dave Anderson wrote:
> "cschang" wrote:>> >
> > while not rs.EOF and rowControl < rs.PageSize
> > If Not isEmpty(previousOne) Then
> > If Cstr(previousOne) <> Cstr(rs(1)) Then
> > Response.Write ...
> > End If
> > end If
> > Response.Write ...
> > ..
> > previousOne = rs(1)
> > rs.MoveNext
> > rowControl = rowControl + 1
> > Wend
> Welcome to Default Property Hell. Your problem stems from your mistaken
> belief that rs(1) is a value. It is an object with the default property
> [Value]. To get around your problem, stop using default properties. The
> correct syntax in this case (Assuming an ADODB.Recordset):
>
> previousOne = rs.Fields(1).Value
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per message. Use
> of this email address implies consent to these terms. Please do not contact
> me directly or ask me to contact you directly for assistance. If your
> question is worth asking, it's worth posting.cschang Guest



Reply With Quote

