Urgent, The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

Rate It (1)

Last post 11-07-2007 6:48 AM by jocker_wow. 4 replies.

Sort Posts:

  • Urgent, The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

    09-27-2007, 4:24 AM
    • Loading...
    • jocker_wow
    • Joined on 01-19-2007, 3:20 AM
    • Egypt
    • Posts 81

    Hi,

    I'm having a BIG problem, this is my 3rd day looking for answer !

    I'm trying to create a custom membership provider with MS SQL database 2005 but not the default ASPNETDB.
    I've changed the web.config to be as following:

    <connectionStrings>

    <
    add name="sqlConn" connectionString="Data Source=.;Integrated Security=True;Initial Catalog=ASPNETDB;"
    providerName="System.Data.SqlClient" />

    </
    connectionStrings> <system.web>

    <
    trace enabled="true" />
    <
    roleManager enabled="true" />
    <
    authentication mode="Forms" />

    <membership defaultProvider="MySqlProvider">
    <
    providers>

    <
    remove name="AspNetSqlProvider"/>
    <
    add name="MySqlProvider" connectionStringName="SqlConn"
    type="System.Web.Security.SqlMembershipProvider" applicationName="/" />

    </
    providers>
    </
    membership>

    But when I try to login to the site using the login control the following error occurs:

    Server Error in '/etest' Application.

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

    Source Error:

    Line 149:    <roleManager>
    Line 150:      <providers>
    Line 151:        <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    Line 152:        <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    Line 153:      </providers>

    Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config    Line: 151


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.213

     It is clear that this is a prblem with my Machine.Config file - since I've "worked!" on this file for a while. But when I've checked the Machine.config file I've found the LocalSqlServer connection it is talking about! Tongue Tied .

    I'm lost and I dunno what to do, can anyone help?

    Here is the mahine.config in case if you need it:

    <connectionStrings>

    <add name="LocalSqlServer" connectionString="data source=.;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />

    </connectionStrings>

    <system.data>

    <DbProviderFactories>

    <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    <add name="SQL Server CE Data Provider" invariant="Microsoft.SqlServerCe.Client" description=".NET Framework Data Provider for Microsoft SQL Server 2005 Mobile Edition" type="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

    </DbProviderFactories>

    </system.data>

    <system.web>

    <processModel autoConfig="true" />

    <httpHandlers />

    <membership>

    <providers>

    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />

    </providers>

    </membership>

    <profile>

    <providers>

    <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </providers>

    </profile>

    <roleManager>

    <providers>

    <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </providers>

    </roleManager>

    </system.web>

    Regards...
    M.Nagieb
    Jocker_Wow
  • Re: Urgent, The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

    09-27-2007, 9:55 AM
    • Loading...
    • manchanda
    • Joined on 09-24-2007, 8:52 AM
    • Posts 4

     hi

    i don't know this will help u or not but i think u r trying this connection with wizard but try it with codes .

     

    here i have some of them .

    public partial class _Default : System.Web.UI.Page
    {  
        SqlConnection con = new SqlConnection();
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter();
        protected void Page_Load(object sender, EventArgs e)
        { 
            SqlConnection con = new SqlConnection("uid=sa;pwd=sa;database=office");//codes for Sql connection .
            SqlDataAdapter da = new SqlDataAdapter("select*from record",con );
            SqlCommand cmd = new SqlCommand();
            DataSet ds=new DataSet() ;
            da.Fill(ds, "tbl1");
    //Connectivity through SQL in gird view
            GridView1.DataSource = ds;
            GridView1.DataBind();
            DataTable dt = ds.Tables[0];
    /
        }

  • Re: Urgent, The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

    09-27-2007, 10:09 AM
    • Loading...
    • jguadagno
    • Joined on 03-17-2003, 7:02 AM
    • Chandler, AZ
    • Posts 587

    I believe the connectionStringName element is case sensitive. Try this.

     

    1    <connectionStrings>
    2    
    3    <add name="sqlConn" connectionString="Data Source=.;Integrated Security=True;Initial Catalog=ASPNETDB;"
    4    providerName="System.Data.SqlClient" />
    5    
    6    </connectionStrings> <system.web>
    7    
    8    <trace enabled="true" />
    9    <roleManager enabled="true" />
    10   <authentication mode="Forms" />
    11   
    12   <membership defaultProvider="MySqlProvider">
    13   <providers>
    14   
    15   <remove name="AspNetSqlProvider"/>
    16   <add name="MySqlProvider" connectionStringName="sqlConn"
    17   type="System.Web.Security.SqlMembershipProvider" applicationName="/" />
    18   
    19   </providers>
    20   </membership>
    
      Look at line 16.
    Joseph Guadagno
    My Website: http://www.josephguadagno.net
    My Blog - http://weblogs.asp.net/jguadagno/

    If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
    That way future readers will know which post solved your issue.
  • Re: Urgent, The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

    11-07-2007, 6:45 AM
    • Loading...
    • jocker_wow
    • Joined on 01-19-2007, 3:20 AM
    • Egypt
    • Posts 81

     The problem was fixed. But just for records, The connection string was written in the Web.Config file and not by wizard .. Thanks!

    manchanda:

     hi

    i don't know this will help u or not but i think u r trying this connection with wizard but try it with codes .

     

    here i have some of them .

    public partial class _Default : System.Web.UI.Page
    {  
        SqlConnection con = new SqlConnection();
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter();
        protected void Page_Load(object sender, EventArgs e)
        { 
            SqlConnection con = new SqlConnection("uid=sa;pwd=sa;database=office");//codes for Sql connection .
            SqlDataAdapter da = new SqlDataAdapter("select*from record",con );
            SqlCommand cmd = new SqlCommand();
            DataSet ds=new DataSet() ;
            da.Fill(ds, "tbl1");
    //Connectivity through SQL in gird view
            GridView1.DataSource = ds;
            GridView1.DataBind();
            DataTable dt = ds.Tables[0];
    /
        }

    Regards...
    M.Nagieb
    Jocker_Wow
  • Re: Urgent, The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

    11-07-2007, 6:48 AM
    • Loading...
    • jocker_wow
    • Joined on 01-19-2007, 3:20 AM
    • Egypt
    • Posts 81

     Thanks jguadagno,

    The problem was the incomplete/incorrect membership provider.

    Thanks!

    jguadagno:

    I believe the connectionStringName element is case sensitive. Try this.

     

    1    <connectionStrings>
    2    
    3    <add name="sqlConn" connectionString="Data Source=.;Integrated Security=True;Initial Catalog=ASPNETDB;"
    4    providerName="System.Data.SqlClient" />
    5    
    6    </connectionStrings> <system.web>
    7    
    8    <trace enabled="true" />
    9    <roleManager enabled="true" />
    10   <authentication mode="Forms" />
    11   
    12   <membership defaultProvider="MySqlProvider">
    13   <providers>
    14   
    15   <remove name="AspNetSqlProvider"/>
    16   <add name="MySqlProvider" connectionStringName="sqlConn"
    17   type="System.Web.Security.SqlMembershipProvider" applicationName="/" />
    18   
    19   </providers>
    20   </membership>
    

      Look at line 16.

     

    Regards...
    M.Nagieb
    Jocker_Wow
Page 1 of 1 (5 items)
Microsoft Communities
Page view counter