Problem getting values from mysql...

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

    Problem getting values from mysql...

    Hello all,

    I am building a vb.net app, using mysql and corelabs connector.
    I am having a bit of difficulty with a dbnull error. Here is some
    sample code:

    Do While myReader3.Read( )
    txtFname.Text = myReader3("fnam e")
    txtLname.Text = myReader3("lnam e")
    txtMiddle.Text = myReader3("midd le")
    txtAddress.Text = myReader3("addr ess")
    txtAddress2.Tex t = myReader3("addr ess2")
    txtCity.Text = myReader4("city code") <- Error starts here
    txtState.Text = myReader4("stat e_code")
    txtHphone.Text = myReader4("hpho ne")
    txtWkphone.Text = myReader4("wkph one")
    txtCell.Text = myReader4("cell phone")
    Loop

    The problem is, I get a dbnull error at "citycode". In order to pull
    the rest of the data (there are 26 fields I am trying to extract), I
    have to open a new connection, get the next 6 values, close, reopen
    and get the next 6 values. NONE of the fields are null!
    Does anyone have any idea why this would occur??? I am totally
    stumped!

    TIA,

    Daniel
  • Ken Tucker [MVP]

    #2
    Re: Problem getting values from mysql...

    Hi,

    I have no experience using the corelabs connection. I have had a
    lot of luck using the mysql dot net connector. I would try that instead.



    Ken
    --------------------------------
    "wink martindale" <wink@martindal e.com> wrote in message
    news:h9roh111ha 48fjvohqtbee48h rd3acpr28@4ax.c om...[color=blue]
    > Hello all,
    >
    > I am building a vb.net app, using mysql and corelabs connector.
    > I am having a bit of difficulty with a dbnull error. Here is some
    > sample code:
    >
    > Do While myReader3.Read( )
    > txtFname.Text = myReader3("fnam e")
    > txtLname.Text = myReader3("lnam e")
    > txtMiddle.Text = myReader3("midd le")
    > txtAddress.Text = myReader3("addr ess")
    > txtAddress2.Tex t = myReader3("addr ess2")
    > txtCity.Text = myReader4("city code") <- Error starts here
    > txtState.Text = myReader4("stat e_code")
    > txtHphone.Text = myReader4("hpho ne")
    > txtWkphone.Text = myReader4("wkph one")
    > txtCell.Text = myReader4("cell phone")
    > Loop
    >
    > The problem is, I get a dbnull error at "citycode". In order to pull
    > the rest of the data (there are 26 fields I am trying to extract), I
    > have to open a new connection, get the next 6 values, close, reopen
    > and get the next 6 values. NONE of the fields are null!
    > Does anyone have any idea why this would occur??? I am totally
    > stumped!
    >
    > TIA,
    >
    > Daniel[/color]


    Comment

    • Mathivanan

      #3
      Re: Problem getting values from mysql...


      First check whether the field value is null or not. For example
      if(dr["Name"].IsDbNull)
      txtName.Text="" ;
      else
      txtName.Text=dr["Name"].toString();

      Regards,
      Mathivanan


      --
      Mathivanan
      ------------------------------------------------------------------------
      Mathivanan's Profile: http://www.msusenet.com/member.php?userid=5148
      View this thread: http://www.msusenet.com/t-1871035314

      Comment

      Working...