Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

"Invalid attempt to read when no data is present."

Back to Forum: Tech Off
  • User profile image
    jsampsonPC

    I am getting this error from my dataReaders, I'm assuming. Here's my setup. Can anybody figure out why it's giving me this error?

    Function something1(args) as string

        Put SELECT query in Command
        dim dataReader and executeReader

        while dataReader.read()
           build string
        end while

        close dataReader

        return string
    end Function

    Function something2(args) as string

        Put SELECT query in Command
        dim dataReader and executeReader

        while dataReader.read()
           build string
        end while

        close dataReader

        return string
    end Function

    main Sub(args)

        dim sqlConnection
        dim sqlCommand

        open connection

        ' Call something1, and pass Conn and Comm
        something1(Conn, Comm, SpecialNum)

        ' Call something2, and pass Conn and Comm
        something2(Conn, Comm, SpecialNum)

        close Connection

    end Sub

  • User profile image
    jsampsonPC

    Nevermind...I'm sorry - I'm such an idiot.

    I didn't perform the .Read() method of my datareader before trying to read from it....what a foolish mistake Smiley

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.