B
Bob Barrows
OK, you've intrigued me. I am going to try to reproduce this on my machine.
It's an Access database, right? Can you give me an example of the data that
produces this error... wait a minute. I bet I know what the issue is. Let me
go and test it. I'll be right back ...
No, that's not it. I thought that the failure to explicitly specify the
field's value property was causing the problem, i.e.:
Response.Write rs(0) + "<BR>"
vs
Response.Write rsFields(0).value + "<BR>"
but that turned out not to be the problem - both of these statements worked
well for me. So the only alternative is that in your table, rs(0) is not a
Text column. In fact, using a numeric column was the only way I could
reproduce your error:
rs.Open "SELECT NumberColumn FROM tblblogs",cn, _
,,adCmdText
Response.Write rs(0) + "<BR>"
I made a mistake in my first reply in this thread. If you go back and
re-read the documentation
(http://msdn.microsoft.com/library/en-us/script56/html/vsidxconcatenation.as
p), you will see that when a number and a string are the addends of the +
operator, addition is attempted, not concatenation. So,
Response.Write 1 + "<BR>"
will cause a type mismatch, since "<BR>" cannot be coerced to a number.
Response.Write 1 + "1"
will result in 2
Response.Write Cstr(1) + "1"
will result in "11"
To reiterate, when using the + operator, concatenation only occurs when both
addends are strings.
Using & will cause both addends to be converted to strings, no matter what
datatype they are initially, so concatenation will always occur.
HTH,
Bob Barrows
It's an Access database, right? Can you give me an example of the data that
produces this error... wait a minute. I bet I know what the issue is. Let me
go and test it. I'll be right back ...
No, that's not it. I thought that the failure to explicitly specify the
field's value property was causing the problem, i.e.:
Response.Write rs(0) + "<BR>"
vs
Response.Write rsFields(0).value + "<BR>"
but that turned out not to be the problem - both of these statements worked
well for me. So the only alternative is that in your table, rs(0) is not a
Text column. In fact, using a numeric column was the only way I could
reproduce your error:
rs.Open "SELECT NumberColumn FROM tblblogs",cn, _
,,adCmdText
Response.Write rs(0) + "<BR>"
I made a mistake in my first reply in this thread. If you go back and
re-read the documentation
(http://msdn.microsoft.com/library/en-us/script56/html/vsidxconcatenation.as
p), you will see that when a number and a string are the addends of the +
operator, addition is attempted, not concatenation. So,
Response.Write 1 + "<BR>"
will cause a type mismatch, since "<BR>" cannot be coerced to a number.
Response.Write 1 + "1"
will result in 2
Response.Write Cstr(1) + "1"
will result in "11"
To reiterate, when using the + operator, concatenation only occurs when both
addends are strings.
Using & will cause both addends to be converted to strings, no matter what
datatype they are initially, so concatenation will always occur.
HTH,
Bob Barrows