c# error with database query transactions
-
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?
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)
-
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?
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[^]
-
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)
-
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?
Read the link I gave you.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
-
Read the link I gave you.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
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
-
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
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)
-
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)
"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); } }
-
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)
-
where must i add these methods ? there is a specific location so when the application start these methods call automatically? where i call them??
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 lineusing 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)
-
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 lineusing 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)
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);
}
} -
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);
}
}See MSDN: Guid.ToString Method[^]
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
-
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 lineusing 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)
-
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?
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)
-
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 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
-
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
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)
-
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)