Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I wish I knew about this site years ago. It would have saved me a lot of heartaches..."

Geography

Where in the world do Tek-Tips members come from?

Input string was not in a correct format. - DataReader

primagic (IS/IT--Management)
4 Sep 12 18:30
I am trying to populate textboxes and a dropdown list on the page when loading using the following code:

CODE

Dim dtrReaderUser As SqlDataReader = SqlCommand.ExecuteReader()
        If dtrReaderUser.HasRows Then
            
            While dtrReaderUser.Read()
                Me.txtFirstname.Text = dtrReaderUser("Firstname")
                Me.txtSurname.Text = dtrReaderUser("Surname")
                Me.txtCompany.Text = dtrReaderUser("Company")
                Me.txtAddressLine1.Text = dtrReaderUser("AddressLine1")
                Me.txtAddressLine2.Text = dtrReaderUser("AddressLine2")
                Me.txtAddressLine3.Text = dtrReaderUser("AddressLine3")
                Me.txtTown.Text = dtrReaderUser("Town")
                Me.txtPostcode.Text = dtrReaderUser("Postcode")
                Me.ddlCountries.SelectedItem.Selected = dtrReaderUser("Country")
                Me.txtPhone.Text = dtrReaderUser("ContactPhone")
                Me.txtEmail.Text = dtrReaderUser("EmailAddress")

            End While 

All the fields populate apart fromthe dropdown list - Me.ddlCountries.SelectedItem.Selected = dtrReaderUser("Country")

I get the error "Input string was not in a correct format."

Any ideas how I would make the selected item the value stored in the database?

MarkSweetland (MIS)
4 Sep 12 20:26

Assuming the dropdown list has string values assigned:

CODE

Me.ddlCountries.SelectedValue = dtrReaderUser("Country").toString() 


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close