How to store ExecuteScalar value into a variable?

  • Hey guys, I am having some strange problem here. My code is as below:

    cmd.connection = cnn

    cmd.commandtext = "select count(*) from member"

    dim i as integer

    i = CInt(cmd.executeScalar)

    However, it return the result "&H0" to me! When i check my query in sqlquery, it did show me the result as "11".

    I have no idea on what is goin on, any help is appreaciated.ty.

  • soli guys, my code is correct. I have make a mistake... =P

    cmd.connection = cnn

    cmd.commandtext = "select count(*) from member"

    label.text = CInt(cmd.ExecuteScalar)

    Anywhere, thanks u guys all =)

  • Are you ignoring trapped errors?

    e.g. no permission to table

    If command fails, ExecuteScalar will return nothing and CInt will convert it to zero.

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply