我正在尝试托管我的第一个ASP.NET项目,在通过FTP进行初始上传后我得到了SQL连接错误,所以在做了一些搜索后我发现它是我的连接字符串,所以我通过正确放置我的主机来修复它信息:
<add name="orangefreshConnectionString1" connectionString="Data Source=<server>;Initial Catalog=<catalog>;User Id=<user>;Password=<pwd>;" providerName="System.Data.SqlClient" />
所以这解决了我的问题,我的网站现在正在...除了我尝试登录时,我得到另一个SQL连接错误。
我在我的网站上使用了2个数据库: dbstart和ASPNETDB(最后一个用于成员资格)
ASPNETDB在我的开发web.config上处理为: 提供商&GT;
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
我知道这里有一些需要改变的地方,但到目前为止我的谷歌查询找不到答案......
这是我的开发web.config内容:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="orangefreshConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\orangefresh.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="orangefreshEntities" connectionString="metadata=res://*/App_Code.Orangefresh.csdl|res://*/App_Code.Orangefresh.ssdl|res://*/App_Code.Orangefresh.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\orangefresh.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<roleManager enabled="true" />
<authentication mode="Forms">
<forms loginUrl="default.aspx"></forms>
</authentication>
<pages theme="orangefresh" />
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
</compilation>
<httpRuntime requestValidationMode="2.0" />
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="João <email@email.com>">
<network host="host" userName="user" password="pass" />
</smtp>
</mailSettings>
</system.net>
<location path="Management">
<system.web>
<authorization>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
</configuration>
如何在web.config上正确引用我的会员资格数据库?
答案 0 :(得分:3)
内部改变:
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
的
connectionStringName="LocalSqlServer"
到
connectionStringName="orangefreshConnectionString1"
或
connectionStringName="orangefreshEntities"
我无法分辨你使用哪种连接,但这就是需要改变的地方。
答案 1 :(得分:0)
是的,您备份原始SQL数据库,然后从顶部恢复。但你不能只从恢复开始。您需要准备好工具。在SQL还原上,您需要检查替换选项。此外,在数据库的安全性方面,您可能需要删除并重新添加用户,并且用户可能具有相同的名称,但可能不是相同的内部ID。