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. Static Vs. Non-Static Connection - C#, SQL Servier in a Multi-User Environment

Static Vs. Non-Static Connection - C#, SQL Servier in a Multi-User Environment

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studioarchitecturelearning
7 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.
  • P Offline
    P Offline
    Prasanth MS
    wrote on last edited by
    #1

    I am a beginner in C# Windows Application Development. I have developed an application with accounting package in three-tier architecture. I am using a single static sql connection for entire application at present. But I am not thinking it's a good practice. Please advise

    S L 2 Replies Last reply
    0
    • P Prasanth MS

      I am a beginner in C# Windows Application Development. I have developed an application with accounting package in three-tier architecture. I am using a single static sql connection for entire application at present. But I am not thinking it's a good practice. Please advise

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, I thin you have a problem within your windows app, if it uses multi-threading. If you use transactions for example, running two or more transactions with one single connection will fail. But if you didn't use multi-threading within you app, everything should be okay. Problem will be when using your tiers within a web app (since the hosting is a single app with multi-threads for each session/request). To be able to give you a more specific answer, you have to be more detailed about your app. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      P 1 Reply Last reply
      0
      • S SeMartens

        Hi, I thin you have a problem within your windows app, if it uses multi-threading. If you use transactions for example, running two or more transactions with one single connection will fail. But if you didn't use multi-threading within you app, everything should be okay. Problem will be when using your tiers within a web app (since the hosting is a single app with multi-threads for each session/request). To be able to give you a more specific answer, you have to be more detailed about your app. Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        P Offline
        P Offline
        Prasanth MS
        wrote on last edited by
        #3

        As I already mentioned, I am beginner and I have developed the three-tier application referring many links in the internet. Eventhough my application can work on multi-user environment, now the customer is working only with one computer and works fine. I have tested the same on two machines and works fine. Please note my applications contains the following files 1. APPL.EXE // Contains only Menu and 3. FRONTEND.DLL // Front End Forms 2. BUSINESSLAYER.DLL // Business Layer 3. DATALAYER.DLL // Data Layer 4. REPORTS.DLL // Crystal Reports and Forms to view the same. On loading Appl.exe, I am opening a static sqlConnection and using the static connection on datalayer.dll. This is because when I want to copy the application to another customer I have to change only the code on APPL.EXE. I have also implemented the same on using another class and works fine. But I want to know when I have to implement the software on another computer, Whether I have to copy all the files to the second machine or copy the APPL.EXE file to the second machine and refer the DLL files on the Server. If you want more details, please inform.

        S 1 Reply Last reply
        0
        • P Prasanth MS

          As I already mentioned, I am beginner and I have developed the three-tier application referring many links in the internet. Eventhough my application can work on multi-user environment, now the customer is working only with one computer and works fine. I have tested the same on two machines and works fine. Please note my applications contains the following files 1. APPL.EXE // Contains only Menu and 3. FRONTEND.DLL // Front End Forms 2. BUSINESSLAYER.DLL // Business Layer 3. DATALAYER.DLL // Data Layer 4. REPORTS.DLL // Crystal Reports and Forms to view the same. On loading Appl.exe, I am opening a static sqlConnection and using the static connection on datalayer.dll. This is because when I want to copy the application to another customer I have to change only the code on APPL.EXE. I have also implemented the same on using another class and works fine. But I want to know when I have to implement the software on another computer, Whether I have to copy all the files to the second machine or copy the APPL.EXE file to the second machine and refer the DLL files on the Server. If you want more details, please inform.

          S Offline
          S Offline
          SeMartens
          wrote on last edited by
          #4

          You can't refer to the DLL-files on the server. You have to copy all libraries to the pc of your customer. Since the app is running on this pc, there is no problem in using a static connection, since the connection is only used by the app on this pc. But let us talk about the system design. If your intention is that only the frontend-library will be delivered to the customer you have to think about using a client/server architecture (web-frontend or sth with webservices). But pay attention when implementing this pattern, there you can't use a static connection since your server will use multiple threads and this won't work well with static variables. Regards Sebastian

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          P 1 Reply Last reply
          0
          • S SeMartens

            You can't refer to the DLL-files on the server. You have to copy all libraries to the pc of your customer. Since the app is running on this pc, there is no problem in using a static connection, since the connection is only used by the app on this pc. But let us talk about the system design. If your intention is that only the frontend-library will be delivered to the customer you have to think about using a client/server architecture (web-frontend or sth with webservices). But pay attention when implementing this pattern, there you can't use a static connection since your server will use multiple threads and this won't work well with static variables. Regards Sebastian

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            P Offline
            P Offline
            Prasanth MS
            wrote on last edited by
            #5

            THANK YOU VERY MUCH..... As of now, since this is a small/ medium application, the current design may be OK. If I want to copy only the font end, whether I should require individual connection. I am asking this question because, if some of customer wants web front end, whether I have to change the entire back end code, because all the class on the same is using a single static sqlConnection. Please advise. Once again thanking you for your great advise. REGARDS PRASANTH

            S 1 Reply Last reply
            0
            • P Prasanth MS

              THANK YOU VERY MUCH..... As of now, since this is a small/ medium application, the current design may be OK. If I want to copy only the font end, whether I should require individual connection. I am asking this question because, if some of customer wants web front end, whether I have to change the entire back end code, because all the class on the same is using a single static sqlConnection. Please advise. Once again thanking you for your great advise. REGARDS PRASANTH

              S Offline
              S Offline
              SeMartens
              wrote on last edited by
              #6

              Yes, if your customer wants a web-frontend you have to change your classes so that they are not using a single statice sqlConnection. Regards Sebastian

              It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

              1 Reply Last reply
              0
              • P Prasanth MS

                I am a beginner in C# Windows Application Development. I have developed an application with accounting package in three-tier architecture. I am using a single static sql connection for entire application at present. But I am not thinking it's a good practice. Please advise

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                The data access layer is not supposed to know what the frontend and business logic layers are doing, or how they do it; hence it must allow for multi-threading and it should not be based on a single static DB connection. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


                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