使用VS2010登录的SQL SERVER

用户名

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=&quot;Localhost\SQLEXPRESS&quot;;
         Initial Catalog=Saqib;Integrated Security=SSPI;
         AttachDBFilename=|D:\SAQIB|\aspnetdb.mdf;
         User Instance=true; User ID=sa;Password=angel"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

我创建一个connectionstring访问本地主机数据库。我的代码在下面,请建议我是否正确?因为当我在浏览器上运行登录页面时,会出现以下错误:

Server Error in '/SAQIB1' Application.
Invalid value for key 'attachdbfilename'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'.
Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
里夫

通常,当您指定db文件名时,将使用| DataDirectory |。占位符。它是一个替换字符串,用于表示db文件的位置,如下所示:

"AttachDBFilename=|DataDirectory|database.mdf;"

在您的情况下,您要指定自己的值,而不使用DataDirectory,因此请排除|。字符和您的设置将是:

AttachDBFilename=D:\SAQIB\aspnetdb.mdf;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

SQL CLR问题VS2010 SQL Server 2012

使用 terraform 添加 Azure SQL Server 登录

使用SQL Server创建登录页面

使用MAP文件VS2010 MFC

可以使用SSMS和VS连接和访问SQL Server数据库,但在报告代码中登录失败

SQL Server 2012登录异常

无法从PHP页面使用本地Dabase用户登录SQL Server

c# 尝试使用远程 sql server 登录但不工作

SQL Server 2008无法使用新创建的用户登录

使用Windows身份验证的SQL Server登录

使用代码(C#)保存SQL Server登录名

使用Active Directory凭据登录Microsoft SQL Server

SQL Server 使用 Pivot 计算每年每月登录次数

使用MacOS终端连接到SQL Server时登录失败

使用Python连接到SQL Server时,用户“”登录失败

无法使用 sqlcmd 远程登录 SQL Server 数据库

使用向导生成的VS2010 WPF项目未编译

在VS2010中,使用openMP firstprivate是否失败?

在VS2010中使用SignalR出现启动错误

使用Windows用户或SQL Server数据库用户,哪个是更安全的登录SQL Server的方法?

基于文本框的 SQL Server 删除/插入无法工作。- VS 2010

通过代码发送数据集时,VS2010 Crystal Reports要求登录。

结合使用TFS 2010源代码管理和SQL Server 2012 SSMS来管理SQL脚本

ODBC连接上的SQL Server登录错误

SQL Server Azure“用户登录失败”

SA sql server linux docker登录失败

在 SQL SERVER 中实现 for 循环登录

登录后阶段连接SQL Server超时

登录到Microsoft SQL Server错误:18456