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. Web Development
  3. ASP.NET
  4. exception

exception

Scheduled Pinned Locked Moved ASP.NET
6 Posts 4 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.
  • N Offline
    N Offline
    NRHSR
    wrote on last edited by
    #1

    Object cannot be cast from DBNull to other types. code is flag = System.Convert.ToInt32(ord["flag"]); i have declared it as int and it can be null in table. can any body give solution for this..... quickly.......

    A K 2 Replies Last reply
    0
    • N NRHSR

      Object cannot be cast from DBNull to other types. code is flag = System.Convert.ToInt32(ord["flag"]); i have declared it as int and it can be null in table. can any body give solution for this..... quickly.......

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      use int flag = (ord["flag"] == DBNull.Value ? default(int) : ord["flag"]); please replace the datatype of flag in default(int) to the data type of flag

      Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
      Create .NET Templates

      N 1 Reply Last reply
      0
      • A Abhishek Sur

        use int flag = (ord["flag"] == DBNull.Value ? default(int) : ord["flag"]); please replace the datatype of flag in default(int) to the data type of flag

        Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
        Create .NET Templates

        N Offline
        N Offline
        NRHSR
        wrote on last edited by
        #3

        its not working

        Y A 2 Replies Last reply
        0
        • N NRHSR

          its not working

          Y Offline
          Y Offline
          Yusuf
          wrote on last edited by
          #4

          take Abhishek reply and apply casting.

          Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

          1 Reply Last reply
          0
          • N NRHSR

            its not working

            A Offline
            A Offline
            Abhishek Sur
            wrote on last edited by
            #5

            yah.. need to cast means Convert.ToInt32(ord["flag"]) Now It will work.:rose:

            Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
            Create .NET Templates

            1 Reply Last reply
            0
            • N NRHSR

              Object cannot be cast from DBNull to other types. code is flag = System.Convert.ToInt32(ord["flag"]); i have declared it as int and it can be null in table. can any body give solution for this..... quickly.......

              K Offline
              K Offline
              keyur satyadev
              wrote on last edited by
              #6

              here you have declare the variable as nullable. int try it.

              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