Be nice

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top