[英]Connection to SQL server database in ASP
I know my question is basic. 我知道我的问题很基本。 But I don't Know how should I configure
web.config
information! 但是我不知道该如何配置
web.config
信息!
My SQL server is connected with windows authentication. 我的SQL Server与Windows身份验证连接。 I'm using this config:
我正在使用此配置:
<add key="DBServer" value="mssql" />
<add key="DBSource" value="localhost" />
<add key="DBName" value="TestDB" />
<add key="LoginName" value="KARIM-PC\Karim" />
<add key="LoginPWD" value="" />
but I get this error: 但是我得到这个错误:
{"This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. Supply an unopened connection."}
{“此操作需要与'master'数据库的连接。由于原始数据库连接已打开并且凭据已从连接字符串中删除,因此无法创建与'master'数据库的连接。提供未打开的连接。”}
Exception: Thrown: "Login failed for user 'KARIM-PC\\Karim'."
例外:抛出:“用户'KARIM-PC \\ Karim'的登录失败。” (System.Data.SqlClient.SqlException) A System.Data.SqlClient.SqlException was thrown: "Login failed for user 'KARIM-PC\\Karim'."
(System.Data.SqlClient.SqlException)引发了System.Data.SqlClient.SqlException:“用户'KARIM-PC \\ Karim'的登录失败。”
对于窗口身份验证
<add name="MyDbConn" connectionString="Initial Catalog=MyDataBaseNAme;Data Source=MyServerName;Integrated Security=SSPI;"/>
I recommend you this site: https://www.connectionstrings.com/sql-server/ for getting more information about connection strings. 我建议您访问以下站点: https : //www.connectionstrings.com/sql-server/以获取有关连接字符串的更多信息。 In your case I think it will suits you:
就您而言,我认为它适合您:
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.