Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. odbc.dll system.nullreferenceexception

odbc.dll system.nullreferenceexception

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mertli Ozgur Nevres
    wrote on last edited by
    #1

    Hi i am using an OdbcDataReader. But i can't read the fields, except the 0. field. I get "system.nullreferenceexception". my code is like below: this is working: MessageBox.Show( objOdbcDR.GetInt32(0).ToString() ); this is throwing the exception: MessageBox.Show( objOdbcDR.GetString(1) ); does anyone know why? thanks. Ozgur Nevres

    H 1 Reply Last reply
    0
    • M Mertli Ozgur Nevres

      Hi i am using an OdbcDataReader. But i can't read the fields, except the 0. field. I get "system.nullreferenceexception". my code is like below: this is working: MessageBox.Show( objOdbcDR.GetInt32(0).ToString() ); this is throwing the exception: MessageBox.Show( objOdbcDR.GetString(1) ); does anyone know why? thanks. Ozgur Nevres

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Does your SQL query select more than one column?

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      M 1 Reply Last reply
      0
      • H Heath Stewart

        Does your SQL query select more than one column?

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        M Offline
        M Offline
        Mertli Ozgur Nevres
        wrote on last edited by
        #3

        yes, 8 columns

        H 1 Reply Last reply
        0
        • M Mertli Ozgur Nevres

          yes, 8 columns

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          You did call OdbcDataReader.Read before making any calls, didn't you? BTW, it's hard to know what to ask to diagnose the problem because you gave very little information. Perhaps some surrounding code (from getting the OdbcDataReader to closing it) would be more helpful. The problem is most likely not with the immediate statement that throws an exception.

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups