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. Having problems with Int32 column

Having problems with Int32 column

Scheduled Pinned Locked Moved Visual Basic
databasecsssql-serversysadminhelp
3 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 am trying to put some info from the database and datatable into a data grid and I get an error on the phone number fields when trying to display the info in the dataGrid control. Here is the error I get. It says it can't store the info in the column. The type is Int 32, expecting Int32. In the database in this column I am using a bigint in sql server express 2005. Here is my code.

    dt.Columns.Add(New DataColumn("Cell", GetType(Long)))

    For Each row As DataRow In dtStud.Rows

     dr(3) = row("stud\_phone")
     dt.Rows.Add(dr)
    

    Next

    'Dim dgView As New DataView(dt)
    dgrStudList.DataSource = dt

    Can anyone tell me why it expects int32 when I am using a Long for the data table column.

    C 1 Reply Last reply
    0
    • A AAGTHosting

      I am trying to put some info from the database and datatable into a data grid and I get an error on the phone number fields when trying to display the info in the dataGrid control. Here is the error I get. It says it can't store the info in the column. The type is Int 32, expecting Int32. In the database in this column I am using a bigint in sql server express 2005. Here is my code.

      dt.Columns.Add(New DataColumn("Cell", GetType(Long)))

      For Each row As DataRow In dtStud.Rows

       dr(3) = row("stud\_phone")
       dt.Rows.Add(dr)
      

      Next

      'Dim dgView As New DataView(dt)
      dgrStudList.DataSource = dt

      Can anyone tell me why it expects int32 when I am using a Long for the data table column.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Where is dr created ? Are you sure that the row you're adding is the third row ?

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      A 1 Reply Last reply
      0
      • C Christian Graus

        Where is dr created ? Are you sure that the row you're adding is the third row ?

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

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

        here is my code.

        Dim dt As New DataTable()
        Dim dr As Data.DataRow

        For Each row As DataRow In dtStud.Rows
        dr = dt.NewRow()
        dr(0) = row("stud_name")
        dr(1) = row("stud_par_name")
        dr(2) = row("stud_id")

                ' get student instruments
                Call studentInstruments(Convert.ToInt32(row("stud\_id")))
        
                ' create counter
                Dim intCount As Integer = 1
        
                For Each row2 As DataRow In dtStudInst.Rows
                    If intCount = 1 Then
                        strInst = Convert.ToString(row2("less\_instrument"))
                    Else
                        strInst += ", " & Convert.ToString(row2("less\_instrument"))
                    End If
                Next
        
                dr(3) = row("stud\_phone")
                dr(4) = row("stud\_cell")
                dr(5) = strInst
        
                dt.Rows.Add(dr)
            Next
        
        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