[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Config file database

Posted on 2005-05-10
8
Medium Priority
?
312 Views
Last Modified: 2010-04-23
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.AppSettings("DatabaseLocation")
but i get:
Name 'configuration settings' is not declared.

Any ideas?
0
Comment
Question by:matt_swinburne
  • 4
  • 4
8 Comments
 
LVL 8

Accepted Solution

by:
doobdave earned 375 total points
ID: 13969613
Hi Matt,

I have a similar config file, and use the follownig code to retrieve values from it:

dbLocation = Configuration.ConfigurationSettings.AppSettings.Item("DatabaseLocation")

HTH

David
0
 

Author Comment

by:matt_swinburne
ID: 13969731
Unfortunatley it uses the configurationsettings and so i am still gettign the same error.  From what i have read you shouldnt have to declare configurationsettings and it should be auto generated by .net at some point?
0
 
LVL 8

Expert Comment

by:doobdave
ID: 13969781
Is that the EXACT error msg you're getting? I only ask 'cos there seems to be a space between "configuration" and "settings"...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:matt_swinburne
ID: 13971403
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.ConfigurationSettings.AppSettings.Item("DatabaseLocation")

thanks for the help
0
 
LVL 8

Expert Comment

by:doobdave
ID: 13976488
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.
0
 

Author Comment

by:matt_swinburne
ID: 13976812
Hi Doob i have solved the problem now but thanks for your help neway
0
 
LVL 8

Expert Comment

by:doobdave
ID: 13976947
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
0
 

Author Comment

by:matt_swinburne
ID: 13979160
I used the following code to bind my db;

Dim dbLocation As String

        dbLocation = System.Configuration.ConfigurationSettings.AppSettings("DatabaseLocation")
       

        OleDbConnection1.ConnectionString = "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\Actual\Actual.mdb"/>
</appSettings>
</configuration>


Hope this helps anyone with similar problems
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question