IIS和SQL服务器之间的连接字符串

编程入门 行业动态 更新时间:2024-10-23 10:21:52
本文介绍了IIS和SQL服务器之间的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在项目的实体框架的Web API Web.config文件中的连接字符串混淆。有很多的变种我试过的,但他们都不是帮助我。目前,连接字符串

I'm confused by the connection string in the Web.config file of project with Entity Framework Web API. There are a lot of variants I tried, but none of them was helping me out. Currently the connection string is

<connectionStrings> <add name="DefaultConnection" connectionString="Server=.\SQLEXPRESS;Database=MyProject;User Id=John;Password=duck;" providerName="System.Data.SqlClient" /> </connectionStrings>

我可以访问被称为2012 MyProject的在SQL Server Management Studio中的数据库(甚至远程),使用约翰作为用户名,烤鸭作为密码。

I can access the database which is called MyProject in SQL Server Management Studio 2012 (even from remote), using John as username and duck as password.

该项目是由IIS服务器在同一台计算机的SQL服务器上运行时,SQL Server的实例名称为 SQLEX $ P $干燥综合征。  我的网页上显示本地主机,但控制器只是回复 500 INTERAL服务器错误每当从SQL数据库的一些数据请求。它看起来像有到数据库的连接。

The project is run by an IIS server on the same machine as the SQL server, the SQL server's instance name is SQLEXPRESS. My webpage is displayed on localhost, but the controller just replies 500 Interal server error whenever some data from the sql database is requested. It looks like there is no connection to the database.

我有什么补充或者为了得到betweeen IIS和SQL服务器的连接发生变化,或者我怎么能找到问题的原因比较好?

What do I have to add or change in order to get a connection betweeen IIS and SQL server, or how can I locate better the problem's cause?

推荐答案

这的教程如何设置SQL Server 2008中的IIS 7.0上ASP网站给我带来接近的解决方案。

This tutorial how to setup SQL Server 2008 for an ASP website on IIS 7.0 brought me close to the solution.

基本上,你需要做的就是

Basically, what you need to do is

  • 安装SQL Server。
  • 允许TCP / IP连接到SQL服务器。
  • 附加数据库。
  • 创建一个登录。我使用的是SQL身份验证。
  • 分配用户权限的数据库。
  • 配置您的数据库连接字符串。
  • 更改我的连接字符串的名称帮我终于建立连接。

    Changing the name of my connection string helped me establish the connection finally.

    <connectionStrings> <add name="MyProjectContext" connectionString="Server=.\SQLEXPRESS;Database=MyProject;User Id=John;Password=duck;" providerName="System.Data.SqlClient" /> </connectionStrings>

    上下文模型所需要这个名字。

    The context model required this name.

    public class MyProjectContext : DbContext { public MyProjectContext() : base("name=MyProjectContext") { } public DbSet<Model1> Model1 { get; set; } public DbSet<Model2> Model2 { get; set; } }

    更多推荐

    IIS和SQL服务器之间的连接字符串

    本文发布于:2023-10-30 22:46:57,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1544221.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:字符串   服务器   IIS   SQL

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!