matt_swinburne
asked on
Config file database
I am using an application configuration file to store the location of a database but am not sure of the syntax in getting the dblocation from the config file. (app.config)
Using this in the config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Location" value="\\network\folder\"/ >
</appSettings>
</configuration>
Tried this code in the main form
Dim dbLocation As String
dbLocation = ConfigurationSettings.AppS ettings("D atabaseLoc ation")
but i get:
Name 'configuration settings' is not declared.
Any ideas?
Using this in the config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Location" value="\\network\folder\"/
</appSettings>
</configuration>
Tried this code in the main form
Dim dbLocation As String
dbLocation = ConfigurationSettings.AppS
but i get:
Name 'configuration settings' is not declared.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is that the EXACT error msg you're getting? I only ask 'cos there seems to be a space between "configuration" and "settings"...
ASKER
what do you mean seems to be a space? I cant see one? (Copied and pasted your line in and said same thing)
dbLocation = Configuration.Configuratio nSettings. AppSetting s.Item("Da tabaseLoca tion")
thanks for the help
dbLocation = Configuration.Configuratio
thanks for the help
Where you outline the error msg you receive:
"Name 'configuration settings' is not declared."
Is this the EXACT error message you get when you attempt to run your code?
Or do you get a blue line under your code with the message you specify appearing in the task list?
If not, please provide the exact message, as this could give us a clue as to what the problem may be.
"Name 'configuration settings' is not declared."
Is this the EXACT error message you get when you attempt to run your code?
Or do you get a blue line under your code with the message you specify appearing in the task list?
If not, please provide the exact message, as this could give us a clue as to what the problem may be.
ASKER
Hi Doob i have solved the problem now but thanks for your help neway
Ok,
maybe you can post how you solved it so that others who may encounter the same problem in the future will be able to get a solution... up to you, otherwise ask tech support to delete this question and refund your points.
Regards,
David
maybe you can post how you solved it so that others who may encounter the same problem in the future will be able to get a solution... up to you, otherwise ask tech support to delete this question and refund your points.
Regards,
David
ASKER
I used the following code to bind my db;
Dim dbLocation As String
dbLocation = System.Configuration.Confi gurationSe ttings.App Settings(" DatabaseLo cation")
OleDbConnection1.Connectio nString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=" & dbLocation & ";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider="" Microsoft. Jet.OLEDB. 4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"
And in my config file i used the following code;
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DatabaseLocation" value= "C:\Documents and Settings\matthewm\Desktop\ Project\Ac tual\Actua l.mdb"/>
</appSettings>
</configuration>
Hope this helps anyone with similar problems
Dim dbLocation As String
dbLocation = System.Configuration.Confi
OleDbConnection1.Connectio
And in my config file i used the following code;
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DatabaseLocation" value= "C:\Documents and Settings\matthewm\Desktop\
</appSettings>
</configuration>
Hope this helps anyone with similar problems
ASKER