Values from Reader

  • Thread starter Joe via DotNetMonster.com
  • Start date
J

Joe via DotNetMonster.com

Hi,

I'm trying to get the values from the reader to display in form fields and
it works when I have a varchar value but not when I have an int. I'm doing
the following:

reader.Read()

MediaName.Text = reader.GetString(0)
PageText.Text = reader.GetString(1)
PageNumber.Text=reader.GetInt(0).T0String()
 
K

Karl Seguin

What doesn't work, do you get an error? does it not display what you had
hoped?

it's GetInt32 first of all..and ToString() not T0String but I imagine that
was just a typo....and finally you are doing a GetString(0) and a
GetInt32(0) is column 0 a varchar or an int?

Karl
 
J

Jeffrey Palermo

Joe,
If that is the actual code you ran, then it will never work like that.
First, you get a string from index 0, and then two lines down you try
to get an int from index 0. There is no way these two lines will ever
succeed. I imagine you may have a second resultset coming back, and if
that is the case, then you need to get the Next resultset before you
can read the values from it.

Best regards,
Jeffrey Palermo
Blog: http://www.jeffreypalermo.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top