|
-
Jun 17th, 2008, 01:59 AM
#1
Thread Starter
Fanatic Member
[Resolved]][02/03]Problem Retrieving a Connection String from App.Config
Hi all
i have the Following App.Config file in VB2003 and a Windows Application.
Code:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="timer.Enabled" value="True" />
<add key="timer.Interval" value="1000" />
<connectionstring>
<add name = "Tshwane_Train"
ConnectionString = "login=sa;Password=tfjgssf;Database=Tshwane_Valuations_Train;
Server=SGIICOR"/>
</connectionstring>
</appSettings>
</configuration>
and am Accessing this Connction string from the Vb App, like this
Code:
Dim constr As String = Configuration.ConfigurationSettings.AppSettings("Tshwane_Train")
Wheni compile the Application, i get no Errors ,but but when i try to run the application, i mean the Part that will need to Connect to the Database i get the Following Error.
Code:
An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: Unrecognized element
What is Wrong
-
Jun 17th, 2008, 06:55 AM
#2
Re: [02/03]Problem Retrieving a Connection String from App.Config
Have you manually opened the file to ensure ("Tshwane_Train") really does exist?
-
Jun 17th, 2008, 08:05 AM
#3
Thread Starter
Fanatic Member
Re: [02/03]Problem Retrieving a Connection String from App.Config
yes ,
it shows in the App.Config File i have posted. am i missing Something? , If i write the name in the App.Config file do i have to write it somewhere else again.
Thanks
-
Jun 17th, 2008, 08:25 AM
#4
Re: [02/03]Problem Retrieving a Connection String from App.Config
replace
Code:
<connectionstring>
<add name = "Tshwane_Train"
ConnectionString = "login=sa;Password=tfjgssf;Database=Tshwane_Valuations_Train;
Server=SGIICOR"/>
</connectionstring>
with
Code:
<add name = "Tshwane_Train"
value= "login=sa;Password=tfjgssf;Database=Tshwane_Valuations_Train;
Server=SGIICOR"/>
__________________
Rate the posts that helped you 
-
Jun 17th, 2008, 09:01 AM
#5
Thread Starter
Fanatic Member
Re: [02/03]Problem Retrieving a Connection String from App.Config
hi man
Thanks for your help, i have changed the App.Config file to the way you advised like and it looked like this
Code:
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="timer.Enabled" value="True" />
<add key="timer.Interval" value="1000" />
<add name = "Tshwane_Train"
Value= "login=sde;Password=topology;Database=Tshwane_Valuations_Train;
Server=SGIICORNETGS01"/>
</appSettings>
</configuration>
and the Code in my VB is Still the Same
Code:
Dim constr As String = Configuration.ConfigurationSettings.AppSettings("Tshwane_Train")
and it Throws an Error that says
Code:
An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: Required attribute 'key' not found
Thanks
-
Jun 17th, 2008, 09:12 AM
#6
Re: [02/03]Problem Retrieving a Connection String from App.Config
remove additional space....
Code:
<add name = "Tshwane_Train"
Value= "login=sde;Password=topology;Database=Tshwane_Valuations_Train;
Server=SGIICORNETGS01"/>
should be
Code:
<add name="Tshwane_Train"
value="login=sde;Password=topology;Database=Tshwane_Valuations_Train;
Server=SGIICORNETGS01"/>
Edit :
Code:
<add key="Tshwane_Train"
value="login=sde;Password=topology;Database=Tshwane_Valuations_Train;
Server=SGIICORNETGS01"/>
Last edited by riteshjain1982; Jun 17th, 2008 at 09:16 AM.
__________________
Rate the posts that helped you 
-
Jun 17th, 2008, 09:22 AM
#7
Thread Starter
Fanatic Member
Re: [02/03]Problem Retrieving a Connection String from App.Config
hi, now my App.Config will look like this
Code:
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="timer.Enabled" value="True" />
<add key="timer.Interval" value="1000" />
<add key="Tshwane_Train"
Value="login=sde;Password=topology;Database=Tshwane_Valuations_Train;
Server=SGIICORNETGS01"/>
</appSettings>
</configuration>
i have removed the Space as Advised and i have this Error
Code:
An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: Required attribute 'key' not found
Thanks
-
Jun 17th, 2008, 09:39 AM
#8
Re: [02/03]Problem Retrieving a Connection String from App.Config
Value should be (small case)
__________________
Rate the posts that helped you 
-
Jun 17th, 2008, 09:44 AM
#9
Thread Starter
Fanatic Member
Re: [02/03]Problem Retrieving a Connection String from App.Config
Wow thanks man
We are Getting Somewhere now, why does it resfuse the login, Doesnt it treat it like a String, ok, after i fixed that m, i got the Following Error
Code:
Additional information: Keyword not supported: 'login'.
Thanks man you are a Star
-
Jun 17th, 2008, 09:47 AM
#10
Re: [02/03]Problem Retrieving a Connection String from App.Config
change to it should work
Code:
"uid=sde;Password=topology;Database=Tshwane_Valuations_Train;Server=SGIICORNETGS01"
__________________
Rate the posts that helped you 
-
Jun 17th, 2008, 09:55 AM
#11
Thread Starter
Fanatic Member
Re: [02/03]Problem Retrieving a Connection String from App.Config
I would like to take this Chance to Thank you for your Patience and your help. I have Added a Reputation to your Answers. you are not just a Good Developer but a A Good Person. if you Continue with that attitude you will go places , mybe as am talking you are places , because people have seen what you got.
Thanks man
-
Jun 17th, 2008, 10:01 AM
#12
Re: [Resolved]][02/03]Problem Retrieving a Connection String from App.Config
Glad that worked for you
__________________
Rate the posts that helped you 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|