Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 来自IIS7的MSSQL连接_C#_Sql Server_Visual Studio 2012_Ssl_Iis 7 - Fatal编程技术网

C# 来自IIS7的MSSQL连接

C# 来自IIS7的MSSQL连接,c#,sql-server,visual-studio-2012,ssl,iis-7,C#,Sql Server,Visual Studio 2012,Ssl,Iis 7,VS是个麻烦事 使用IIS Express进行调试时(不创建SSL证书或任何东西),一切正常:DB连接、AD连接、SQL连接。 当使用自签名证书在IIS 7上发送所有内容时,一切都不起作用,所有内容都会抛出错误,我没有VS调试工具 为什么会出现以下代码 dbconn = new SqlConnection("user id=test;password=test;server=server01;Trusted_Connection=true;TrustServerCertifica

VS是个麻烦事

使用IIS Express进行调试时(不创建SSL证书或任何东西),一切正常:DB连接、AD连接、SQL连接。 当使用自签名证书在IIS 7上发送所有内容时,一切都不起作用,所有内容都会抛出错误,我没有VS调试工具

为什么会出现以下代码

        dbconn = new SqlConnection("user id=test;password=test;server=server01;Trusted_Connection=true;TrustServerCertificate=true;database=test;connection timeout=5");
        try
        {
            dbconn.Open();
        }
        catch (Exception e)
        {
            Debug.Message("dbconn.open failed: " + e.Message);
        }
在我的开发机器上运行时工作,但在server03上的IIS7上返回

dbconn.open failed: Login failed for user 'INTRA\SERVER03$'.

特别是为什么用户“INTRA\SERVER03$”(顺便说一句,它不存在),而不是我在连接字符串中明确指定的用户?

问题在于连接字符串,应该设置为:

user id=test;password=test;server=server01;TrustServerCertificate=true;database=test;connection timeout=5
完成此操作后,下一个问题可能是“SELECT权限被拒绝”,这是因为我的sql用户“test”没有设置为数据库“test”的db_datareader(在SSMS中的Security=>Logins下)

这给了我一个很好的后续问题:为什么它在IIS Express中工作