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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problem with datatype in database insert

Problem with datatype in database insert

Scheduled Pinned Locked Moved Visual Basic
databasehelpannouncement
5 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.
  • A Offline
    A Offline
    AAGTHosting
    wrote on last edited by
    #1

    I have 2 phone number fields in the database that right now are a text dataType. They were an int, then I changed them to varchar(13). When I try to do an insert into the database there is an exception that says the following.

    Failed to convert paramater value from a string to an Integer.

    Here is my code. I declared addRow globally. addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(addRow) Catch err As Exception MessageBox.Show(err.Message) End Try

    D 1 Reply Last reply
    0
    • A AAGTHosting

      I have 2 phone number fields in the database that right now are a text dataType. They were an int, then I changed them to varchar(13). When I try to do an insert into the database there is an exception that says the following.

      Failed to convert paramater value from a string to an Integer.

      Here is my code. I declared addRow globally. addRow = lpDataSet.Tables("tbl_students").NewRow() addRow("stud_cell") = txtStudCell.Text addRow("stud_phone") = txtStudPhone.Text lpDataSet.Tables("tbl_students").Rows.Add(addRow) Try studTableAdapter.Update(addRow) Catch err As Exception MessageBox.Show(err.Message) End Try

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      AAGTHosting wrote:

      Try studTableAdapter.Update(addRow)

      Me thinks you didn't update the DataSet to change the datatype of the phone number field.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      A 1 Reply Last reply
      0
      • D Dave Kreskowiak

        AAGTHosting wrote:

        Try studTableAdapter.Update(addRow)

        Me thinks you didn't update the DataSet to change the datatype of the phone number field.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        A Offline
        A Offline
        AAGTHosting
        wrote on last edited by
        #3

        I checked the dataSet and it says the phone number field is text. Also, when I try to do an insert the info does not get inserted into the database.

        D 1 Reply Last reply
        0
        • A AAGTHosting

          I checked the dataSet and it says the phone number field is text. Also, when I try to do an insert the info does not get inserted into the database.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          AAGTHosting wrote:

          I checked the dataSet and it says the phone number field is text.

          Well, the code is throwing an exception that says otherwise. After changing the field type in the database, did you do ANYTHING to update the schema of the dataset?? If not, then it's not updated and it's still using an Integer type for one of those fields.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          A 1 Reply Last reply
          0
          • D Dave Kreskowiak

            AAGTHosting wrote:

            I checked the dataSet and it says the phone number field is text.

            Well, the code is throwing an exception that says otherwise. After changing the field type in the database, did you do ANYTHING to update the schema of the dataset?? If not, then it's not updated and it's still using an Integer type for one of those fields.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            A Offline
            A Offline
            AAGTHosting
            wrote on last edited by
            #5

            I did update the schema of the dataset. In fact, when I tried to change the dataType in the designer it was already text.

            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