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