You need to be aware of the differences between the "normal version" of SQL Server, and the Express edition.
The Express edition is used by default to autogenerate a database by the .NET Framework (as instructed with the default LocalSqlServer (or whatever it's called exactly) connection string in the machine's root config file.)
If you want to use SQL Server, you should not try to use SQL Express and have the attached database appear in the aspnet_regsql tool's Databases list. I have tried that a couple of times, but it never quite worked. I think this is caused by the UserMode property that also detaches the database again. Also, there is a fair chance that under SQL 2005 Standard edition, your database is stored *outside* the App_Data folder, and stored somewhere under the Data folder of SQL Server, or another location you choose.
Anyway, here's what you should do (and what has worked for me many times).
1. Run the aspnet_regsql tool.
2. Point to your SQL Server installation (either 2000, or 2005, don't use Express)
3. Have it configure the database. Afterwards, you'll see the new tables, procedures, views and so on
4. Add a connection string to your web.config. This is a normal SQL Server connection string. E.g.:
<add name="YourConnectionString" connectionString="server=YourServer;Initial
Catalog=YourDatabase;Integrated Security=true;"/>
5. Configure the providers. The following snippet shows the code for the Membership and Role providers:
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="YourConnectionString" enablePasswordRetrieval="False" enablePasswordReset="True" requiresQuestionAndAnswer="False" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<roleManager defaultProvider="SqlProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
<providers>
<add name="SqlProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="YourConnectionString"/>
</providers>
</roleManager>
The trick here is to either create a brand new provider (as demo-ed here with the RoleManager provider code above). In that case you need the defaultProvider attribute to have it point to your provider settings.
Alternatively, reuse the *name* of an existing. In that case, you'll need to <remove /> or <clear /> the old providers, as you can see in the config for the Membership provider.
Either way, you use the connectionStringName attribute to point to the connection string you created in step 4.
So, the steps explained in the Blog do work as advertised. You just misunderstood the instructions. The seemingly simple step 1 may actually mean creating a database through the Enterprise Manager or the new SQL Server 2005 studio under a SQL Server instance, and then create a connection string to the instance (using examples from ConnectionStrings.com). Then you'll need to know the name of your database server, instance and database to point to the right database in the regsql tool.
I guess Scott assumed his readers knew how to do this but I agree he could have provided more details.
Does this help?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to:
English Summer Rain by
Placebo (Track 2 from the album:
Sleeping with Ghosts)
What's This?