Hi all,
First ASP.NET project - please be gentle !
OK. Ready to add personalisation and membership. I have VS2005 Professional, including SQL Server 2005 developer, but I understand that VS2005 defaults to creating a local SQL Express file in the App_Data directory and that suits me just fine for now. Unfortunately I can't get VS to create it for me and the ASP.NET Configuration tool complains it can't connect to the database.
First, some REALLY dumb questions to show how little I really know ...
I can go to the VS command prompt and run aspnet_regsql.exe in wizard mode. Going through the steps on that I could give it my SQL Server 2005 server name (after I start it) but that's not what I'm trying to do. I just want it to create and connect to a local file in the App_Data.
machine.config shows ...
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<!-- <add name="LocalSql2005" connectionString="Data Source=MICKSPC\SSLMJ;Initial Catalog=aspnetdb;Integrated Security=True"
providerName="System.Data.SqlClient" />
-->
</connectionStrings>
The commented connection string I used to temporarily prove that I could access SQL2005. It's no longer used and I've put the other references back to "LocalSqlServer" as below ...
<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>The profile provider is clearly pointing to "LocalSqlServer" which in turn points to : connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
What am I missing please ?
Do you have sql express installed?|||(Shrugs embarrassment off).
I originally had it installed - but removed it (along with VS Studio Express) when I bought VS2005. Sorry.
Would you mind clarifying SQL Express a little for me. Is there any point in installing and using it if I have Sql 2005 ? The only reason I could see was to have a file which was portable within the App_Data directory rather than running scripts to update a remote database. However if I use Sql Express then presumably that software would have to be installed on my remote shared host and I can't guarantee that.
Thanks - and sorry for the dumb question.
|||Sql express is a free version of sql server 2005. Visual Studio is setup to attach the database to sql express by default. In tools--> options--> database tools if you change the Sql Server Instance name to a blank string it will use your SQL Server 2005
No comments:
Post a Comment