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. How to Close any opened Connections to a database?

How to Close any opened Connections to a database?

Scheduled Pinned Locked Moved C#
databasehelptutorialquestion
9 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.
  • C Offline
    C Offline
    CoderForEver
    wrote on last edited by
    #1

    Hi everybody, I've made a POS System and @ the exit I want to make an automatic Backup which copies the database to some place ... but it says the database is used ... & I tried to find where it is unclosed (it is thousand of lines of code).... and I cant get it ... so can anybody help me ... how write some line of code which will close any opened connection to that database? .. Thank you

    P S 2 Replies Last reply
    0
    • C CoderForEver

      Hi everybody, I've made a POS System and @ the exit I want to make an automatic Backup which copies the database to some place ... but it says the database is used ... & I tried to find where it is unclosed (it is thousand of lines of code).... and I cant get it ... so can anybody help me ... how write some line of code which will close any opened connection to that database? .. Thank you

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Perhaps Management Studio has the database open? If so, you have to close Management Studio; I don't think you can close another application's connection, at least it shouldn't be your standard operating method.

      modified on Thursday, December 3, 2009 2:19 PM

      C 2 Replies Last reply
      0
      • P PIEBALDconsult

        Perhaps Management Studio has the database open? If so, you have to close Management Studio; I don't think you can close another application's connection, at least it shouldn't be your standard operating method.

        modified on Thursday, December 3, 2009 2:19 PM

        C Offline
        C Offline
        CoderForEver
        wrote on last edited by
        #3

        I didnt get what you said... Can you elaborate it to me

        1 Reply Last reply
        0
        • P PIEBALDconsult

          Perhaps Management Studio has the database open? If so, you have to close Management Studio; I don't think you can close another application's connection, at least it shouldn't be your standard operating method.

          modified on Thursday, December 3, 2009 2:19 PM

          C Offline
          C Offline
          CoderForEver
          wrote on last edited by
          #4

          I knew that... but wat i wanted is how to close all connections that are opened @ that time

          1 Reply Last reply
          0
          • C CoderForEver

            Hi everybody, I've made a POS System and @ the exit I want to make an automatic Backup which copies the database to some place ... but it says the database is used ... & I tried to find where it is unclosed (it is thousand of lines of code).... and I cant get it ... so can anybody help me ... how write some line of code which will close any opened connection to that database? .. Thank you

            S Offline
            S Offline
            Shorgov
            wrote on last edited by
            #5

            Do you know how to use google? I tried with - "kill connections sql server" and all of the top 10 results had the answer.

            A 1 Reply Last reply
            0
            • S Shorgov

              Do you know how to use google? I tried with - "kill connections sql server" and all of the top 10 results had the answer.

              A Offline
              A Offline
              Ashfield
              wrote on last edited by
              #6

              BUT, to kill connections (not your own) you need sa rights, not something which most accounts should have.

              Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

              S 1 Reply Last reply
              0
              • A Ashfield

                BUT, to kill connections (not your own) you need sa rights, not something which most accounts should have.

                Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                S Offline
                S Offline
                Shorgov
                wrote on last edited by
                #7

                Yap, this is true, but if you are building an administrative module you should grant this kind of rights to the admin of the application.

                A 1 Reply Last reply
                0
                • S Shorgov

                  Yap, this is true, but if you are building an administrative module you should grant this kind of rights to the admin of the application.

                  A Offline
                  A Offline
                  Ashfield
                  wrote on last edited by
                  #8

                  Shorgov wrote:

                  you should grant this kind of rights to the admin of the application.

                  Matter of opinion. It allows far to much damage to be done - do you really want to give a user the right to drop tables etc?

                  Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                  S 1 Reply Last reply
                  0
                  • A Ashfield

                    Shorgov wrote:

                    you should grant this kind of rights to the admin of the application.

                    Matter of opinion. It allows far to much damage to be done - do you really want to give a user the right to drop tables etc?

                    Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                    S Offline
                    S Offline
                    Shorgov
                    wrote on last edited by
                    #9

                    Only to the appropriate user :) In general I am agreed with you, but user not allays means dumb person. User of this admin module can be a developer(responsible for the maintenance of the system ) or a trained consultant who knows what he is doing.

                    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