Hi,

I am developing this app using ASP.NET 2.0, SQL Server 2005 express and VS 2005 express edition. All I am trying to do is use Login Web controls provided in ASP.NET 2.0 for my user login pages. When I go to ASP.NET configuration and click on Security tab I get following error

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

and when I try "Choose Data Source" I get error

Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.

I've ran aspnet_regsql wizard and it has created role and membership tables in my database. I can connect to the database from the other pages of the application. Here is my web.config

<?xml version="1.0"?>
<configuration xmlns="">
	<appSettings>
  <add key="CompanyName" value="Kendall Park Learning Center" />
 </appSettings>
	<connectionStrings>
  <add name="KPLC_OneSourceConnectionString1" connectionString="Data Source=TEXPERT002;Initial Catalog=KPLC_OneSource;Integrated Security=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
	<system.web>
		  <compilation debug="true" strict="false" explicit="true"/>
		<pages>
			<namespaces>
				<clear/>
				<add namespace="System"/>
				<add namespace="System.Collections"/>
				<add namespace="System.Collections.Specialized"/>
				<add namespace="System.Configuration"/>
				<add namespace="System.Text"/>
				<add namespace="System.Text.RegularExpressions"/>
				<add namespace="System.Web"/>
				<add namespace="System.Web.Caching"/>
				<add namespace="System.Web.SessionState"/>
				<add namespace="System.Web.Security"/>
				<add namespace="System.Web.Profile"/>
				<add namespace="System.Web.UI"/>
				<add namespace="System.Web.UI.WebControls"/>
				<add namespace="System.Web.UI.WebControls.WebParts"/>
				<add namespace="System.Web.UI.HtmlControls"/>
			</namespaces>
		</pages>
				<authentication mode="Windows"/>
			</system.web>
</configuration>

Has anyone used login controls with SQL Server 2005 express ? can you please tell me what am I doing wrong ? :sad:

thanks in advance.:)

Tejoo.

Dani AI

Generated

Quick checklist for (what usually trips the ASP.NET Configuration / Security pages)

  • The admin tool must be able to reach the same SQL database that contains the ASP.NET membership/role tables. Common problems are a wrong server/instance in the connection string, the tables being created in a different database/instance, role manager not enabled, or using Windows auth in the site while the login controls expect Forms auth. was right to suggest Forms auth; ’s "reinstall OS" advice can be ignored.

  • Ensure the membership and role providers are explicitly configured to use your connection string (or provide a LocalSqlServer connection string override). Also turn roleManager on so the Security UI can manage roles. Example provider snippet (drop into your system.web):

<membership defaultProvider="SqlProvider">
  <providers>
    <add name="SqlProvider"
         type="System.Web.Security.SqlMembershipProvider"
         connectionStringName="MyMembershipDB"
         applicationName="/"
         enablePasswordReset="true" />
  </providers>
</membership>

<roleManager enabled="true" defaultProvider="SqlRoleProvider">
  <providers>
    <add name="SqlRoleProvider"
         type="System.Web.Security.SqlRoleProvider"
         connectionStringName="MyMembershipDB" />
  </providers>
</roleManager>
  • When you ran aspnet_regsql make sure it targeted the same server/instance your site uses. Example command (run from the .NET v2.0 folder or use full path):
aspnet_regsql.exe -S .\SQLEXPRESS -E -d YourDatabase -A all

Practical troubleshooting steps

  • Open the database in Management Studio and confirm aspnet_* tables exist in the expected DB.
  • Test the exact connection string by opening a SQL connection (or using Management Studio) as that same user/instance.
  • If using Integrated Security, confirm the account the admin tool runs as has DB rights; try a temporary SQL-auth connection string just to rule out permissions.
  • Make sure SQL Server (and SQL Browser for named instances) are running and that the instance name in Data Source is correct.

If these checks still leave the admin tool unhappy, post the provider/role sections and the exact connection-string name (not passwords) so others can spot mismatches quickly.

Recommended Answers

All 3 Replies

Simply Reinstall your windows XP or What ever you have.........

Hi Texpert I would advise you to ignore Jack12's response there, not very good advice. I have had this issue before myself but running the aspnet_regsql resolved it. I might recommend that you retry the utility and get back to us? hope this helps!

make sure your web.config has forms authentication

</namespaces>
</pages>
<authentication mode="Forms"/>
</system.web>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.