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. c# error with database query transactions

c# error with database query transactions

Scheduled Pinned Locked Moved C#
csharpdatabasehelpvisual-studioquestion
17 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.
  • U Offline
    U Offline
    User3490
    wrote on last edited by
    #1

    Hi i make a setup in visual studio 2010 and a make it install to another laptop but the access 2010 database can not make update their queries but we can retrieve information from it. What might be the problem?

    OriginalGriffO L 2 Replies Last reply
    0
    • U User3490

      Hi i make a setup in visual studio 2010 and a make it install to another laptop but the access 2010 database can not make update their queries but we can retrieve information from it. What might be the problem?

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      If you can read from it, but not write to it, then the most likely problem is permissions on the file or the folder you have stored it in. It is probable that you have installed the database file in the application folder, which on the release machine means under one of the "Program Files" folder. Writes to these folders are heavily discouraged, and if you have done that it is a poor idea. It works on your development machine because the application is in the Debug or Release folder of your project - not the "Program Files" folder at all. Have a look here: Where should I store my data?[^] and move you data to a more sensible location!

      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      U 1 Reply Last reply
      0
      • U User3490

        Hi i make a setup in visual studio 2010 and a make it install to another laptop but the access 2010 database can not make update their queries but we can retrieve information from it. What might be the problem?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        zebra88 wrote:

        What might be the problem?

        The fact that Access isn't a database-server, but a client-application. It's not meant to serve multiple clients. I'd suggest you hit the "Upgrade to SQL Server" button after opening the database in the Access-IDE. SQL Server Express is "free", and would be better suited for this particular task.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          If you can read from it, but not write to it, then the most likely problem is permissions on the file or the folder you have stored it in. It is probable that you have installed the database file in the application folder, which on the release machine means under one of the "Program Files" folder. Writes to these folders are heavily discouraged, and if you have done that it is a poor idea. It works on your development machine because the application is in the Debug or Release folder of your project - not the "Program Files" folder at all. Have a look here: Where should I store my data?[^] and move you data to a more sensible location!

          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

          U Offline
          U Offline
          User3490
          wrote on last edited by
          #4

          when i make the setup there are only application, user desktop and user's programs menu folder . Where can i put my access database so the user can be modify?

          OriginalGriffO 1 Reply Last reply
          0
          • U User3490

            when i make the setup there are only application, user desktop and user's programs menu folder . Where can i put my access database so the user can be modify?

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Read the link I gave you.

            The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            U 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              Read the link I gave you.

              The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

              U Offline
              U Offline
              User3490
              wrote on last edited by
              #6

              If i correctly understand i must use one of the following path as my path for my access database but how can i use it in c# ? i must include it somewhere for example the Common.AppGuid where i have to use it? Common.AppGuid 158aa00d-332e-440b-9c2c-47e2fc11c078 Common.AssemblyGuid 8d14ff7e-8d39-4163-a1ba-4fae4a5c361d Common.UserDataFolder C:\Users\griff\AppData\Local\{158AA00D-332E-440B-9C2C-47E2FC11C078}\ Application.UserAppDataPath C:\Users\griff\AppData\Roaming\SetShares\SetShares\1.0.0.0 Common.UserRoamingDataFolder C:\Users\griff\AppData\Roaming\{158AA00D-332E-440B-9C2C-47E2FC11C078}\ Application.LocalUserAppDataPath C:\Users\griff\AppData\Local\SetShares\SetShares\1.0.0.0 Common.AllUsersDataFolder C:\ProgramData\{158AA00D-332E-440B-9C2C-47E2FC11C078}\ Application.CommonAppDataPath C:\ProgramData\SetShares\SetShares\1.0.0.0 thnx

              OriginalGriffO 1 Reply Last reply
              0
              • U User3490

                If i correctly understand i must use one of the following path as my path for my access database but how can i use it in c# ? i must include it somewhere for example the Common.AppGuid where i have to use it? Common.AppGuid 158aa00d-332e-440b-9c2c-47e2fc11c078 Common.AssemblyGuid 8d14ff7e-8d39-4163-a1ba-4fae4a5c361d Common.UserDataFolder C:\Users\griff\AppData\Local\{158AA00D-332E-440B-9C2C-47E2FC11C078}\ Application.UserAppDataPath C:\Users\griff\AppData\Roaming\SetShares\SetShares\1.0.0.0 Common.UserRoamingDataFolder C:\Users\griff\AppData\Roaming\{158AA00D-332E-440B-9C2C-47E2FC11C078}\ Application.LocalUserAppDataPath C:\Users\griff\AppData\Local\SetShares\SetShares\1.0.0.0 Common.AllUsersDataFolder C:\ProgramData\{158AA00D-332E-440B-9C2C-47E2FC11C078}\ Application.CommonAppDataPath C:\ProgramData\SetShares\SetShares\1.0.0.0 thnx

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                Common.AppGuid is a value assigned to you application when you compile it. Just add the methods, and store your file in the folder returned by AllUsersDataFolder

                The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                U 2 Replies Last reply
                0
                • OriginalGriffO OriginalGriff

                  Common.AppGuid is a value assigned to you application when you compile it. Just add the methods, and store your file in the folder returned by AllUsersDataFolder

                  The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                  U Offline
                  U Offline
                  User3490
                  wrote on last edited by
                  #8

                  "Just add the methods, and store your file in the folder returned by AllUsersDataFolder " where i have to add these methods anywhere? because i add them in the same location that i call the connectionstring for my connection with access database in c# but does not recognise the commands that has to make with GuidAttribute: public static Guid AppGuid { get { Assembly asm = Assembly.GetEntryAssembly(); object[] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true)); return new Guid((attr[0] as GuidAttribute).Value); } }

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    Common.AppGuid is a value assigned to you application when you compile it. Just add the methods, and store your file in the folder returned by AllUsersDataFolder

                    The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                    U Offline
                    U Offline
                    User3490
                    wrote on last edited by
                    #9

                    where must i add these methods ? there is a specific location so when the application start these methods call automatically? where i call them??

                    OriginalGriffO 1 Reply Last reply
                    0
                    • U User3490

                      where must i add these methods ? there is a specific location so when the application start these methods call automatically? where i call them??

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #10

                      You probably need to add the using statements. Look at your code where the error is, and place the text cursor inside the word that is underlined in red. A small blue block will appear at the beginning of the word. Hover the mouse over that, and a drop down list will appear. Open the drop down, and it will present you with options to fix the problem. (In this case, probably by adding the line

                      using System.Reflection;

                      for you). (This is based on your previous post, now deleted - but still relevant, I suspect)

                      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      U 2 Replies Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        You probably need to add the using statements. Look at your code where the error is, and place the text cursor inside the word that is underlined in red. A small blue block will appear at the beginning of the word. Hover the mouse over that, and a drop down list will appear. Open the drop down, and it will present you with options to fix the problem. (In this case, probably by adding the line

                        using System.Reflection;

                        for you). (This is based on your previous post, now deleted - but still relevant, I suspect)

                        The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                        U Offline
                        U Offline
                        User3490
                        wrote on last edited by
                        #11

                        what is the B here?

                        public static string UserDataFolder
                        {
                        get
                        {
                        Guid appGuid = AppGuid;
                        string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                        string dir = string.Format(@"{0}\{1}\", folderBase,

                        -------> appGuid.ToString("B").ToUpper());
                        return CheckDir(dir);
                        }
                        }

                        OriginalGriffO 1 Reply Last reply
                        0
                        • U User3490

                          what is the B here?

                          public static string UserDataFolder
                          {
                          get
                          {
                          Guid appGuid = AppGuid;
                          string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                          string dir = string.Format(@"{0}\{1}\", folderBase,

                          -------> appGuid.ToString("B").ToUpper());
                          return CheckDir(dir);
                          }
                          }

                          OriginalGriffO Offline
                          OriginalGriffO Offline
                          OriginalGriff
                          wrote on last edited by
                          #12

                          See MSDN: Guid.ToString Method[^]

                          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                          1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            You probably need to add the using statements. Look at your code where the error is, and place the text cursor inside the word that is underlined in red. A small blue block will appear at the beginning of the word. Hover the mouse over that, and a drop down list will appear. Open the drop down, and it will present you with options to fix the problem. (In this case, probably by adding the line

                            using System.Reflection;

                            for you). (This is based on your previous post, now deleted - but still relevant, I suspect)

                            The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                            U Offline
                            U Offline
                            User3490
                            wrote on last edited by
                            #13

                            where must i add these methods ? there is a specific location so when the application start these methods call automatically? where i can to call them? in program file?

                            OriginalGriffO 1 Reply Last reply
                            0
                            • U User3490

                              where must i add these methods ? there is a specific location so when the application start these methods call automatically? where i can to call them? in program file?

                              OriginalGriffO Offline
                              OriginalGriffO Offline
                              OriginalGriff
                              wrote on last edited by
                              #14

                              Wherever you normally put "generic" helper methods. I would call it once from my main form and save a static string with the whole connection string ready to rock'n'roll when you need to access the file.

                              The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                              U 1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                Wherever you normally put "generic" helper methods. I would call it once from my main form and save a static string with the whole connection string ready to rock'n'roll when you need to access the file.

                                The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                                U Offline
                                U Offline
                                User3490
                                wrote on last edited by
                                #15

                                I don't understand very well what i must do it so the user can make update thee queries to access database without problems when he already run my application program in his laptop the actions that i have to do if i understand correctly is to add the following methods in program.cs but i don't understand how i call ant save it with connection string /// /// Get the Application Guid /// public static Guid AppGuid { get { Assembly asm = Assembly.GetEntryAssembly(); object[] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true)); return new Guid((attr[0] as GuidAttribute).Value); } } /// /// Get the current assembly Guid. /// /// Note that the Assembly Guid is not necessarily the same as the /// Application Guid - if this code is in a DLL, the Assembly Guid /// will be the Guid for the DLL, not the active EXE file. /// /// public static Guid AssemblyGuid { get { Assembly asm = Assembly.GetExecutingAssembly(); object[] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true)); return new Guid((attr[0] as GuidAttribute).Value); } } /// /// Get the current user data folder /// public static string UserDataFolder { get { Guid appGuid = AppGuid; string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string dir = string.Format(@"{0}\{1}\", folderBase, appGuid.ToString("B").ToUpper()); return CheckDir(dir); } } /// /// Get the current user roaming data folder /// public static string UserRoamingDataFolder { get { Guid appGuid = AppGuid; string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string dir = string.Format(@"{0}\{1}\", folderBase, appGuid.ToString("B").ToUpper()); return CheckDir(dir); } } /// /// Get all users data folder /// public static string AllUsersDataFolder { get { Guid appGuid = AppGuid; string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string dir = string.Format(@"{0}\{1}\", folderBase, appGuid.ToString("B").ToUpper()); return CheckDir(dir); } } /// /// Check the specified folder, and

                                OriginalGriffO 1 Reply Last reply
                                0
                                • U User3490

                                  I don't understand very well what i must do it so the user can make update thee queries to access database without problems when he already run my application program in his laptop the actions that i have to do if i understand correctly is to add the following methods in program.cs but i don't understand how i call ant save it with connection string /// /// Get the Application Guid /// public static Guid AppGuid { get { Assembly asm = Assembly.GetEntryAssembly(); object[] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true)); return new Guid((attr[0] as GuidAttribute).Value); } } /// /// Get the current assembly Guid. /// /// Note that the Assembly Guid is not necessarily the same as the /// Application Guid - if this code is in a DLL, the Assembly Guid /// will be the Guid for the DLL, not the active EXE file. /// /// public static Guid AssemblyGuid { get { Assembly asm = Assembly.GetExecutingAssembly(); object[] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true)); return new Guid((attr[0] as GuidAttribute).Value); } } /// /// Get the current user data folder /// public static string UserDataFolder { get { Guid appGuid = AppGuid; string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string dir = string.Format(@"{0}\{1}\", folderBase, appGuid.ToString("B").ToUpper()); return CheckDir(dir); } } /// /// Get the current user roaming data folder /// public static string UserRoamingDataFolder { get { Guid appGuid = AppGuid; string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string dir = string.Format(@"{0}\{1}\", folderBase, appGuid.ToString("B").ToUpper()); return CheckDir(dir); } } /// /// Get all users data folder /// public static string AllUsersDataFolder { get { Guid appGuid = AppGuid; string folderBase = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string dir = string.Format(@"{0}\{1}\", folderBase, appGuid.ToString("B").ToUpper()); return CheckDir(dir); } } /// /// Check the specified folder, and

                                  OriginalGriffO Offline
                                  OriginalGriffO Offline
                                  OriginalGriff
                                  wrote on last edited by
                                  #16

                                  So try it on your computer in the debugger and see what happens. This is not rocket science! :laugh:

                                  The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                  U 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    So try it on your computer in the debugger and see what happens. This is not rocket science! :laugh:

                                    The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                                    U Offline
                                    U Offline
                                    User3490
                                    wrote on last edited by
                                    #17

                                    i have added the methods in program.cs but haven't saw something different from before.. is there any other way to implement setup for my c# project so that working for all laptops without any problems with access 2010 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