Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
How to write connection string in web.config file using asp.net,
 
i just applied this code:
 
<configuration>
	<configsections>
    
        <add name="conn" connectionstring="Data Source=TEKPC26\SQLEXPRESS; <br mode=" hold=" />                       AttachDbFilename=registration.mdf; <br mode=" />
</configsections>
</configuration>
 
but getting one error!
"The element 'configSections' has invalid child element 'add'. List of possible elements expected: 'section, sectionGroup'.
Posted 2-Nov-11 18:59pm
Edited 2-Nov-11 19:03pm
P.Salini14.7K
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Place in this way
You need to place it in configuration tag and outside configsections tag
 
<connectionStrings>
        <add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="server=.;database=YourDB;User id= uidofDB;Password=pwd"/>
    </connectionStrings>
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

check it
 
<configuration>
  <configsections>
    <sectiongroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectiongroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication" />
        <sectiongroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication" />
        </sectiongroup>
      </sectiongroup>
    </sectiongroup>
  </configsections>
  <appsettings>
    <add key="con" value="Data Source=OMXHO11SFD0885\UMA;Initial Catalog=omx;Persist Security Info=True;User ID=sa;Password=pass" />
  </appsettings>
  <connectionstrings>
    <add name="cnn" connectionstring="Data Source=OMXHO11SFD0885\UMA;Initial Catalog=omx;Persist Security Info=True;User ID=sa;Password=pass" providername="System.Data.SqlClient" />
  </connectionstrings>
</configuration>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

u can as:
<add connectionstring="server=.\SQLEXPRESS;database=DatabaseName;Trusted_connection=True;" name="strconnection" providername="System.Data.SqlClient" />
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 432
1 sanket saxena 355
2 Abhinav S 258
3 OriginalGriff 235
4 CPallini 205
0 Sergey Alexandrovich Kryukov 8,704
1 OriginalGriff 5,000
2 Peter Leow 3,839
3 Maciej Los 3,535
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 3 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid