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. C#
  4. Unhandled Exception: System.InvalidOperationException

Unhandled Exception: System.InvalidOperationException

Scheduled Pinned Locked Moved C#
helpcsharpdatabasevisual-studio
4 Posts 3 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.
  • S Offline
    S Offline
    sasire18
    wrote on last edited by
    #1

    hi When I first executed the program it gave me Table inserted successfully and below the error

    Unhandled Exception: System.InvalidOperationException: ExecuteNonQuery requires
    an open and available Connection. The connection's current state is Closed.
    at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean ex
    ecuting)
    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at Examples.Class1.Main() in c:\documents and settings\sasi\my documents\
    visual studio projects\examples\class1.cs:line 34
    Press any key to continue

    After making changes it again me the error connection is aready opened and tables are already existed in the database so i removed the previous changes and deleted the tables from the database .At present I am getting the below error which i cant resolved it.

    Cannot drop the table 'emplo', because it does not exist in the system catalog.
    Press any key to continue

    Please can anyone help me in this !! sasi

    S 1 Reply Last reply
    0
    • S sasire18

      hi When I first executed the program it gave me Table inserted successfully and below the error

      Unhandled Exception: System.InvalidOperationException: ExecuteNonQuery requires
      an open and available Connection. The connection's current state is Closed.
      at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean ex
      ecuting)
      at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
      at Examples.Class1.Main() in c:\documents and settings\sasi\my documents\
      visual studio projects\examples\class1.cs:line 34
      Press any key to continue

      After making changes it again me the error connection is aready opened and tables are already existed in the database so i removed the previous changes and deleted the tables from the database .At present I am getting the below error which i cant resolved it.

      Cannot drop the table 'emplo', because it does not exist in the system catalog.
      Press any key to continue

      Please can anyone help me in this !! sasi

      S Offline
      S Offline
      sathish s
      wrote on last edited by
      #2

      [Message Deleted]

      S 1 Reply Last reply
      0
      • S sathish s

        [Message Deleted]

        S Offline
        S Offline
        sasire18
        wrote on last edited by
        #3

        in my coding I am dropping the tables if it exists else it should not bother about it and then creating the tables in the database ,if i give some other name for the database still it shows me the same error

        Cannot drop the table 'emplo', because it does not exist in the system catalog.
        Press any key to continue

        any idea why it so !! earlier i deleted the table manually from the Enterprise Manager is that the cause for it sasi

        N 1 Reply Last reply
        0
        • S sasire18

          in my coding I am dropping the tables if it exists else it should not bother about it and then creating the tables in the database ,if i give some other name for the database still it shows me the same error

          Cannot drop the table 'emplo', because it does not exist in the system catalog.
          Press any key to continue

          any idea why it so !! earlier i deleted the table manually from the Enterprise Manager is that the cause for it sasi

          N Offline
          N Offline
          Nobia
          wrote on last edited by
          #4

          By Manually deleting the table you did remove it, but there may still be a pointer to the table. In other words the application still thinks the table exists, but cant find it? Try 'Manually' recreating the table (only with minimum data, no need to create entire thing). Then using the proper commands empty the table, THEN delete it. that may fix the problem. otherwise you may need to use a maintenance routine to rebuild your database. ;)

          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