Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with placement of connection string in config file 2

Status
Not open for further replies.

chilly442

Technical User
Jun 25, 2008
151
US
I have a connection string defined as follows:

Code:
<connectionStrings>
     <add name="Con" connectionString="Driver={Microsoft ODBC for Oracle};Server=xxxx;Uid=xxxx;Pwd=xxxx;" providerName="System.Data.ODBC"/>
</connectionStrings>

No matter where I put this in the web config file I get an error.
Where in the config file is the connection string supposed to go?

Stars for help!!!

Thanks,
Chilly442
---------------------------------------
If I lived anywhere else I'd be Sunny442
 
what is the error?

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
The connection string is in the correct format.
This is the error that I am getting.
Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.

I get the same error no matter where I place the connection string.
Code:
<configuration>
 <configSections>
  <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
   <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
     <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
       <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
   </sectionGroup>
  </sectionGroup>
 </sectionGroup>
</configSections>
	<system.web>

This is what the first part of my config file looks like.
Thanks for the help!!!



Thanks,
Chilly442
---------------------------------------
If I lived anywhere else I'd be Sunny442
 
the message says it all. you have two sets of </configSections> in a single config file. you must remove the second. you can place <connectionStrings> below the configSections node.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
There is only one section called configSections. The error is acting like the <connectionStrings> is in the place of the configSections. I deleted the <sectionGroup> part out of my code and put in the connectionString. It works fine now.

Thanks for the help. I sure need it.


Thanks,
Chilly442
---------------------------------------
If I lived anywhere else I'd be Sunny442
 
as an fyi deleting the sectionGroup from the web.config those settings will not be read. this will only be an issue if you are using any of those features.

for example: if you deleted the configGroup 'system.web.extensions' than any configurations within this node (towards the bottom of the file) will not be read by the system because it will not be able to locate them.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks. I have tested the code without the stuff I deleted and have not had any issues yet. I am not even sure where they came from.

Thank you for all your help. You have saved me a few times.

Thanks,
Chilly442
---------------------------------------
If I lived anywhere else I'd be Sunny442
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top