Debugging into SqlCommand.ExecuteReader

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BuddyWork

    #1

    Debugging into SqlCommand.ExecuteReader

    Does anyone know if there are any articles explaining how
    I could debug into SqlCommand.Exec uteReader so I can see
    why I am getting a particular error.

    thanks
  • Vadym Stetsyak

    #2
    Re: Debugging into SqlCommand.Exec uteReader

    What error are you getting?

    "BuddyWork" <anonymous@disc ussions.microso ft.com> wrote in message
    news:22cd01c3fc 57$0cc9ec60$a40 1280a@phx.gbl.. .[color=blue]
    > Does anyone know if there are any articles explaining how
    > I could debug into SqlCommand.Exec uteReader so I can see
    > why I am getting a particular error.
    >
    > thanks[/color]


    Comment

    • Ignacio Machin \( .NET/ C#  MVP \)

      #3
      Re: Debugging into SqlCommand.Exec uteReader

      Hi,

      I don;t think that it's possible, as you don;t have the source code for it
      or its being compiled with debug info the only way is to debug the IL code
      :)
      Anyway, I don't really think that it's necessary, I would suggest you to
      post the problem you have and maybe it's possible to help you without need
      to decompile ExecuteReader() :)

      Cheeers,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation

      "BuddyWork" <anonymous@disc ussions.microso ft.com> wrote in message
      news:22cd01c3fc 57$0cc9ec60$a40 1280a@phx.gbl.. .[color=blue]
      > Does anyone know if there are any articles explaining how
      > I could debug into SqlCommand.Exec uteReader so I can see
      > why I am getting a particular error.
      >
      > thanks[/color]


      Comment

      • BuddyWork

        #4
        Re: Debugging into SqlCommand.Exec uteReader

        Hello,

        The problem is that when using SqlCommand.Exec uteReader
        and the SQL statement raises an error of severity of 16
        then ExecuteReader throws an exception, when you use
        OdbcCommand.Exe cuteReader the exception is not raised but
        when you call Read() method of the OdbcDataReader you then
        get the exception which is correct, basically SqlClient
        does not let you call the Read method, the main problem is
        that if run a Sql statement of say
        'Need to create the following SP first.
        create proc test
        as
        rollback tran
        go

        now run the following SQL through SqlCommand and then
        OdbcCommand
        begin tran
        execute test
        select hello="World"

        you will notice that SqlCommand throws an exception on
        ExecuteReader function where OdbcCommand does not, so Odbc
        allows you to call Read and NextResult to go through the
        recordset and retrieve your data, wher SqlClient does not
        because you don't get the SqlDataReader object back.

        Thanks,[color=blue]
        >-----Original Message-----
        >Hi,
        >
        > I don;t think that it's possible, as you don;t have the[/color]
        source code for it[color=blue]
        >or its being compiled with debug info the only way is to[/color]
        debug the IL code[color=blue]
        >:)
        > Anyway, I don't really think that it's necessary, I[/color]
        would suggest you to[color=blue]
        >post the problem you have and maybe it's possible to help[/color]
        you without need[color=blue]
        >to decompile ExecuteReader() :)
        >
        >Cheeers,
        >
        >--
        >Ignacio Machin,
        >ignacio.mach in AT dot.state.fl.us
        >Florida Department Of Transportation
        >
        >"BuddyWork" <anonymous@disc ussions.microso ft.com> wrote[/color]
        in message[color=blue]
        >news:22cd01c3f c57$0cc9ec60$a4 01280a@phx.gbl. ..[color=green]
        >> Does anyone know if there are any articles explaining[/color][/color]
        how[color=blue][color=green]
        >> I could debug into SqlCommand.Exec uteReader so I can see
        >> why I am getting a particular error.
        >>
        >> thanks[/color]
        >
        >
        >.
        >[/color]

        Comment

        • BuddyWork

          #5
          Re: Debugging into SqlCommand.Exec uteReader

          Hello,

          The problem is that when using SqlCommand.Exec uteReader
          and the SQL statement raises an error of severity of 16
          then ExecuteReader throws an exception, when you use
          OdbcCommand.Exe cuteReader the exception is not raised but
          when you call Read() method of the OdbcDataReader you then
          get the exception which is correct, basically SqlClient
          does not let you call the Read method, the main problem is
          that if run a Sql statement of say
          'Need to create the following SP first.
          create proc test
          as
          rollback tran
          go

          now run the following SQL through SqlCommand and then
          OdbcCommand
          begin tran
          execute test
          select hello="World"

          you will notice that SqlCommand throws an exception on
          ExecuteReader function where OdbcCommand does not, so Odbc
          allows you to call Read and NextResult to go through the
          recordset and retrieve your data, wher SqlClient does not
          because you don't get the SqlDataReader object back.

          Thanks,[color=blue]
          >-----Original Message-----
          >What error are you getting?
          >
          >"BuddyWork" <anonymous@disc ussions.microso ft.com> wrote[/color]
          in message[color=blue]
          >news:22cd01c3f c57$0cc9ec60$a4 01280a@phx.gbl. ..[color=green]
          >> Does anyone know if there are any articles explaining[/color][/color]
          how[color=blue][color=green]
          >> I could debug into SqlCommand.Exec uteReader so I can see
          >> why I am getting a particular error.
          >>
          >> thanks[/color]
          >
          >
          >.
          >[/color]

          Comment

          • Vadym Stetsyak

            #6
            Re: Debugging into SqlCommand.Exec uteReader

            From the documentation:
            "Error messages with a severity level of 10 are informational. Error
            messages with severity levels from 11 through 16 are generated by the user
            and can be corrected by the user"

            executing test store procedure will give you error of severity 16,
            "Server: Msg 3903, Level 16, State 1, Procedure test, Line 3
            The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION."

            so you cannot issue 'rollback' statement without preceding 'begin tran'.

            "BuddyWork" <anonymous@disc ussions.microso ft.com> wrote in message
            news:277f01c3fc 83$4c54d850$a30 1280a@phx.gbl.. .[color=blue]
            > Hello,
            >
            > The problem is that when using SqlCommand.Exec uteReader
            > and the SQL statement raises an error of severity of 16
            > then ExecuteReader throws an exception, when you use
            > OdbcCommand.Exe cuteReader the exception is not raised but
            > when you call Read() method of the OdbcDataReader you then
            > get the exception which is correct, basically SqlClient
            > does not let you call the Read method, the main problem is
            > that if run a Sql statement of say
            > 'Need to create the following SP first.
            > create proc test
            > as
            > rollback tran
            > go
            >
            > now run the following SQL through SqlCommand and then
            > OdbcCommand
            > begin tran
            > execute test
            > select hello="World"
            >
            > you will notice that SqlCommand throws an exception on
            > ExecuteReader function where OdbcCommand does not, so Odbc
            > allows you to call Read and NextResult to go through the
            > recordset and retrieve your data, wher SqlClient does not
            > because you don't get the SqlDataReader object back.
            >
            > Thanks,[color=green]
            > >-----Original Message-----
            > >What error are you getting?
            > >
            > >"BuddyWork" <anonymous@disc ussions.microso ft.com> wrote[/color]
            > in message[color=green]
            > >news:22cd01c3f c57$0cc9ec60$a4 01280a@phx.gbl. ..[color=darkred]
            > >> Does anyone know if there are any articles explaining[/color][/color]
            > how[color=green][color=darkred]
            > >> I could debug into SqlCommand.Exec uteReader so I can see
            > >> why I am getting a particular error.
            > >>
            > >> thanks[/color]
            > >
            > >
            > >.
            > >[/color][/color]


            Comment

            • BuddyWork

              #7
              Re: Debugging into SqlCommand.Exec uteReader

              Thanks for the reply,

              But I don't think you understood my question, basically
              the problem is that Odbc.ExecuteRea der does NOT THROW AN
              EXCEPTION whereas SqlClient.Execu teReader does THROW AN
              EXCEPTION, so because SqlClient.Execu teReader THROWS AN
              EXCEPTION there is NO WAY of retrieving the SqlDataReader
              object which then means you CANNOT go through the
              recordset for each MULTIPLE results returned, I've looked
              at the IL code of SqlClient and can see that data is there
              but SqlClient refuses you to get to it, when Odbc.Net
              allows you to access the data. Please note that Odbc.Net
              THROWS THE EXCEPTION when calling the READ or NEXTRESULT
              method of the OdbcDataReader object.

              THIS IS A BUG IN THERE CODE.

              Thanks
              [color=blue]
              >-----Original Message-----
              >From the documentation:
              >"Error messages with a severity level of 10 are[/color]
              informational. Error[color=blue]
              >messages with severity levels from 11 through 16 are[/color]
              generated by the user[color=blue]
              >and can be corrected by the user"
              >
              >executing test store procedure will give you error of[/color]
              severity 16,[color=blue]
              >"Server: Msg 3903, Level 16, State 1, Procedure test,[/color]
              Line 3[color=blue]
              >The ROLLBACK TRANSACTION request has no corresponding[/color]
              BEGIN TRANSACTION."[color=blue]
              >
              >so you cannot issue 'rollback' statement without[/color]
              preceding 'begin tran'.[color=blue]
              >
              >"BuddyWork" <anonymous@disc ussions.microso ft.com> wrote[/color]
              in message[color=blue]
              >news:277f01c3f c83$4c54d850$a3 01280a@phx.gbl. ..[color=green]
              >> Hello,
              >>
              >> The problem is that when using SqlCommand.Exec uteReader
              >> and the SQL statement raises an error of severity of 16
              >> then ExecuteReader throws an exception, when you use
              >> OdbcCommand.Exe cuteReader the exception is not raised[/color][/color]
              but[color=blue][color=green]
              >> when you call Read() method of the OdbcDataReader you[/color][/color]
              then[color=blue][color=green]
              >> get the exception which is correct, basically SqlClient
              >> does not let you call the Read method, the main problem[/color][/color]
              is[color=blue][color=green]
              >> that if run a Sql statement of say
              >> 'Need to create the following SP first.
              >> create proc test
              >> as
              >> rollback tran
              >> go
              >>
              >> now run the following SQL through SqlCommand and then
              >> OdbcCommand
              >> begin tran
              >> execute test
              >> select hello="World"
              >>
              >> you will notice that SqlCommand throws an exception on
              >> ExecuteReader function where OdbcCommand does not, so[/color][/color]
              Odbc[color=blue][color=green]
              >> allows you to call Read and NextResult to go through the
              >> recordset and retrieve your data, wher SqlClient does[/color][/color]
              not[color=blue][color=green]
              >> because you don't get the SqlDataReader object back.
              >>
              >> Thanks,[color=darkred]
              >> >-----Original Message-----
              >> >What error are you getting?
              >> >
              >> >"BuddyWork" <anonymous@disc ussions.microso ft.com> wrote[/color]
              >> in message[color=darkred]
              >> >news:22cd01c3f c57$0cc9ec60$a4 01280a@phx.gbl. ..
              >> >> Does anyone know if there are any articles explaining[/color]
              >> how[color=darkred]
              >> >> I could debug into SqlCommand.Exec uteReader so I can[/color][/color][/color]
              see[color=blue][color=green][color=darkred]
              >> >> why I am getting a particular error.
              >> >>
              >> >> thanks
              >> >
              >> >
              >> >.
              >> >[/color][/color]
              >
              >
              >.
              >[/color]

              Comment

              Working...