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. Close SqlServer Database

Close SqlServer Database

Scheduled Pinned Locked Moved C#
databasesysadminhelp
3 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.
  • F Offline
    F Offline
    freshonlineMax
    wrote on last edited by
    #1

    Hi I want to close sqlserver opened database from my project. SqlConnection just close the connection, not the database. more info : sqlConnection1.Open(server=computer;database=xdb); . . . sqlconnection1.Close(); . . . RestoreDatabase(xdb); //error:database is in use :doh: Tanx.

    D P 2 Replies Last reply
    0
    • F freshonlineMax

      Hi I want to close sqlserver opened database from my project. SqlConnection just close the connection, not the database. more info : sqlConnection1.Open(server=computer;database=xdb); . . . sqlconnection1.Close(); . . . RestoreDatabase(xdb); //error:database is in use :doh: Tanx.

      D Offline
      D Offline
      Darren Sim
      wrote on last edited by
      #2

      If you are using a datareader you may have to close this as well i.e datareader.Close(); HTH Darren

      1 Reply Last reply
      0
      • F freshonlineMax

        Hi I want to close sqlserver opened database from my project. SqlConnection just close the connection, not the database. more info : sqlConnection1.Open(server=computer;database=xdb); . . . sqlconnection1.Close(); . . . RestoreDatabase(xdb); //error:database is in use :doh: Tanx.

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        You will probably find that the connection is still present because it is pooled.

        Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world." Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that." Deja View - the feeling that you've seen this post before.

        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