更改 ASPNETDB 名称

发布于 2024-07-09 16:41:03 字数 480 浏览 8 评论 0原文

是否有办法更改 ASPNETDB 并使用 SQLExpress (2005) 用户实例?

我已将 web.config 的连接字符串更改为,

<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
     connectionString="Data Source=.\SQLEXPRESS;
     AttachDbFilename=|DataDirectory|\Kooft.mdf;
     User Instance=true;
     Integrated Security=True;
     Initial Catalog=Kooft;"
  providerName="System.Data.SqlClient" />

但每次使用 ASP.Net 配置工具时,它都会在我的 App_Data 文件夹中创建另一个 ASPNETDB.mdf 文件。

Is there anyway to change the ASPNETDB and also using SQLExpress (2005) user instance ?

I have changed my web.config's connectin string to

<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
     connectionString="Data Source=.\SQLEXPRESS;
     AttachDbFilename=|DataDirectory|\Kooft.mdf;
     User Instance=true;
     Integrated Security=True;
     Initial Catalog=Kooft;"
  providerName="System.Data.SqlClient" />

but every time I using ASP.Net Configuration Tool, it will create another ASPNETDB.mdf file in my App_Data folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十雾 2024-07-16 16:41:03
  1. 从 Framework 2.0 文件夹运行 aspnet_regsql.exe,我的是:

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

  2. 完成向导并选择您希望添加 AspNetDB 表的数据库。

    完成

  3. 设置连接字符串以连接到数据库,例如(方括号中的任何内容可能需要更改并删除括号。

  4. 更新 web.config 的会员资格提供程序部分,并将以下设置设置为上面的连接字符串名称:

    connectionStringName="INSERTCONNNSTRINGNAME"

然后您应该准备好滚动。 请记住更改 web.config 中可能已有的任何角色或个性化提供程序的相同设置。

  1. Run aspnet_regsql.exe from your Framework 2.0 folder, mine is:

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

  2. Go through the wizard and choose the database that you wish to add the AspNetDB tables too.

  3. Set the connectionstring to connect to your database e.g. (Anything in square brackets may possibly need changing and the brackets removed.

  4. Update your membership provider section of the web.config and set the following setting to be the connectionstringname from above:

    connectionStringName="INSERTCONNNSTRINGNAME"

Then you should be ready to roll. Remember to change the same setting on any role or personalization providers you may have already in the web.config.

等风来 2024-07-16 16:41:03

首先,在 SQL Express 实例中创建一个新的空数据库。

然后运行可以在此处找到的 aspnet_regsql.exe 工具:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

这将打开一个 GUI 向导,允许您选择数据库服务器和要使用 aspnet 提供程序的默认架构(成员身份、配置文件、角色)设置的数据库。

适当配置数据库的安全性 - 为了获得最佳结果,您可能需要启用集成安全性,因此请确保运行网站的帐户有权访问数据库,为您创建了许多数据库角色 -将您的帐户添加到适当的帐户中。

然后,在您的 webconfig 中,您将看到类似以下内容:

    <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" 
        connectionString="Data Source=[ComputerName]\SQLEXPRESS;Initial Catalog=[DatabaseName];Integrated Security=True" 
        providerName="System.Data.SqlClient"/>
    </connectionStrings>

要更新的关键部分是:

  • [ComputerName] - 这应该是
    SQL Express 的实例名称
    安装。
  • [数据库名称] - 这个
    应该是数据库的名称
    您在前两个步骤中使用了。

这当然就是我的启动和运行的方式。

First, create a new, empty database in your SQL Express instance.

Then run the aspnet_regsql.exe tool that can be found here:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

This will open a GUI wizard allowing you to select a database server and database to be set up with the default schema for the aspnet providers (membership, profile, roles).

Configure the security on the database appropriately - for best results, you probably want to enable Integrated Security, so ensure that the account the web site is runing under has access to the database, there are a number of Database Roles that are created for you - add your account to the appropriate ones.

Then, in your webconfig, you'd have something like:

    <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" 
        connectionString="Data Source=[ComputerName]\SQLEXPRESS;Initial Catalog=[DatabaseName];Integrated Security=True" 
        providerName="System.Data.SqlClient"/>
    </connectionStrings>

The key parts to update there are:

  • [ComputerName] - this should be the
    instance name of your SQL Express
    installation.
  • [DatabaseName] - this
    should be the name of the database
    you used in the first two steps.

That's certainly how I got mine up and running.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文