为什么我无法使用“项目”->“添加”->“新项目”->“SQL Server 数据库”在空 ASP MVC 2 项目中创建数据库?

发布于 2024-08-26 09:38:06 字数 729 浏览 5 评论 0原文

我正在一头扎进 ASP MVC 并尝试创建和操作数据库。我进行了搜索并找到了创建数据库的教程,但是当我按照它进行操作时,在尝试将新数据库添加到我的新空 ASP MVC 2 项目时,我一开始就收到此错误...

与网络相关或特定于实例的 建立时发生错误 连接到 SQL Server。服务器 未找到或无法访问。 验证实例名称是否为 正确并且 SQL Server 是 配置为允许远程 连接。 (提供商:SQL 网络 接口,错误:26 - 错误定位 指定服务器/实例)

教程提到的唯一要求是 SQL Server Express,但是当我去下载它时,它说它已经安装了。我假设它是我安装并正在运行的 VS 2010 RC 的一部分。所以我不知道如果我错过了什么,我还需要什么。 这对我来说是全新的,所以我确信我在这里遗漏了一些明显的东西,在我发布这个问题之后,我计划对数据库主题以及它们如何与 ASP MVC 一起工作进行更多研究。与此同时,你可以帮我回答几个高级问题...

  1. 我错过/忘记做什么导致了这个错误?
  2. 对于专注于在 ASP MVC 中使用数据库的良好资源/教程有什么建议吗?我过去做过很多数据库编程,所以我熟悉关系数据库和 SQL 语言的概念。我希望我能找到一个很好的资源来学习如何在 ASP 开发环境中使用它们,以及用于使用它们的所有相关技术(即 LINQ to SQL)的详细分类。

预先非常感谢您的所有帮助!我现在就开始研究这些问题。

I'm diving head first into ASP MVC and am playing around with creating and manipulating a database. I did a search and found this tutorial for creating a database, however when I follow it, I get this error right at the start when trying to add a new database to my fresh, empty ASP MVC 2 project...

A network-related or instance-specific
error occurred while establishing a
connection to SQL Server. The server
was not found or was not accessible.
Verify that the instance name is
correct and that SQL Server is
configured to allow remote
connections. (provider: SQL Network
Interfaces, error: 26 - Error Locating
Server/Instance Specified)

The only requirement the tutorial mentioned was SQL Server Express, but when I went to download it, it said it was already installed. I'm assuming it was part of the VS 2010 RC I installed and am running. So I don't know what else I need if I am missing something.
This is all new to me, so I'm sure I'm missing something obvious here and after I'm done posting this question, I plan to do some more research into the topic of databases and how they work with ASP MVC. In the meantime, I was you could help me answer a couple high level questions...

  1. What am I missing/forgetting to do that is causing this error?
  2. Any suggestions for good resources/tutorials that focus on using databases with ASP MVC? I've done a lot of database programming in the past, so I'm familiar with the concepts of relational databases and the SQL language. I wish I could find a good resource for learning how to work with them in an ASP dev environment, as well as a good breakdown of all the related technologies used for working with them (i.e. LINQ to SQL).

Thanks so much in advance for all your help! I'm going to start researching these questions right now.

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

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

发布评论

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

评论(1

野の 2024-09-02 09:38:06

您需要验证 VS 使用的连接字符串是否指向有效且正在运行的 SQL Server 实例。除非您修改了某些内容,否则 VS 将尝试连接到名为 SQLEXPRESS 的本地实例(即带有数据源 .\SQLEXPRESS 的连接字符串)。您需要确保您的 SQL Server 正在名为 SQLEXPRESS 的实例中运行。从命令提示符运行 net start mssql$sqlexpress 以启动该服务(如果该服务已停止)。您还需要确保可以连接到所述 SQL Server 实例:看看以管理员身份启动 VS 是否会产生任何影响。如果是这样,那么您需要从以管理员身份运行的命令提示符中显式地将自己添加到 SQL 管理员中:

sqlcmd /S .\SQLEXPRESS /E /Q "create login [<myntdomain>\<myusername>];"
sqlcmd /S .\SQLEXPRESS /E /Q "sp_addsrvgroupmember '<myntdomain>\myusername>','sysadmin';"

替换为您的实际 NT 域名(未加入 AD 域的计算机是其自己的 NT 域)和您的实际用户名, 当然。

You need to verify that the connection string used by VS points to a valid and running SQL Server instance. Unless you modified something, VS will try to connect to a local instance named SQLEXPRESS (ie. a connection string with a datasource .\SQLEXPRESS). You need to make sure that your SQL Server is running in an instance named SQLEXPRESS. Run from a command prompt net start mssql$sqlexpress to start the service if its stopped. You also need to make sure you can connect to said SQL Server instance: see if starting VS as an administrator makes any difference. If it does, then you need to add yourself to the SQL administrators explicitly, from a command prompt started as administrator run:

sqlcmd /S .\SQLEXPRESS /E /Q "create login [<myntdomain>\<myusername>];"
sqlcmd /S .\SQLEXPRESS /E /Q "sp_addsrvgroupmember '<myntdomain>\myusername>','sysadmin';"

Replace with your actual NT domain name (a non AD domain joined machine is its own NT domain) and your actual user name, of course.

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